Add more iconv option completions, use _split_longopt.

This commit is contained in:
Ville Skyttä 2010-04-11 16:40:34 +03:00
parent 6a6cab1179
commit a44c07fb9e
3 changed files with 21 additions and 9 deletions

View File

@ -25,10 +25,10 @@ bash-completion (2.x)
* Apply cardctl completion to pccardctl too. * Apply cardctl completion to pccardctl too.
* Apply pine completion to alpine too. * Apply pine completion to alpine too.
* Remove many unnecessary short option completions where long ones exist. * Remove many unnecessary short option completions where long ones exist.
* Improve chsh, chgrp, chown, configure, cvs, gkrellm, gzip, lftp, look, * Improve chsh, chgrp, chown, configure, cvs, gkrellm, gzip, iconv, lftp,
make, man, mdadm, modprobe, mplayer, mysqladmin, perldoc, rsync, screen, look, make, man, mdadm, modprobe, mplayer, mysqladmin, perldoc, rsync,
service, scp, ssh, sshfs, update-alternatives, vncviewer, yp-tools, and screen, service, scp, ssh, sshfs, update-alternatives, vncviewer, yp-tools,
general hostname completions. and general hostname completions.
* Add abook and wtf completion, based on work by Raphaël Droz. * Add abook and wtf completion, based on work by Raphaël Droz.
* Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake, * Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake,
pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz and unpigz completions. pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz and unpigz completions.

View File

@ -3,24 +3,36 @@
have iconv && have iconv &&
_iconv() _iconv()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-f|-t|--from-code|--to-code) -'?'|--help|--usage|-V|--version|--unicode-subst|--byte-subst|\
--widechar-subst)
return 0
;;
-f|--from-code|-t|--to-code)
COMPREPLY=( $( compgen -W \ COMPREPLY=( $( compgen -W \
'$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) ) '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
return 0 return 0
;; ;;
-o|--output)
_filedir
return 0
;;
esac esac
$split && return 0
if [[ "$cur" = -* ]]; then if [[ "$cur" = -* ]]; then
COMPREPLY=( $( compgen -W '--from-code -f --to-code -t --list COMPREPLY=( $( compgen -W '--from-code --to-code --list -c
--output -o --verbose' -- "$cur" ) ) --unicode-subst --byte-subst --widechar-subst --output --silent
--verbose --help --usage --version' -- "$cur" ) )
return 0 return 0
fi fi
} && } &&

View File

@ -11,7 +11,7 @@ proc teardown {} {
setup setup
assert_complete_any "iconv " assert_complete_any "iconv -"
sync_after_int sync_after_int