summaryrefslogtreecommitdiff
path: root/completions/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'completions/iconv')
-rw-r--r--completions/iconv19
1 files changed, 12 insertions, 7 deletions
diff --git a/completions/iconv b/completions/iconv
index 50edb4c5..2fb1c92d 100644
--- a/completions/iconv
+++ b/completions/iconv
@@ -1,21 +1,26 @@
# iconv(1) completion -*- shell-script -*-
+_iconv_charsets()
+{
+ COMPREPLY+=( $(compgen -W '$(${1:-iconv} -l | \
+ command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur") )
+}
+
_iconv()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
- -'?'|--help|--usage|-V|--version|--unicode-subst|--byte-subst|\
- --widechar-subst)
+ --help|--usage|--version|--unicode-subst|--byte-subst|\
+ --widechar-subst|-!(-*)[?V])
return
;;
- -f|--from-code|-t|--to-code)
- COMPREPLY=( $( compgen -W '$( iconv -l | \
- command sed -e "s@/*\$@@" -e "s/[,()]//g" )' -- "$cur" ) )
+ --from-code|--to-code|-!(-*)[ft])
+ _iconv_charsets $1
return
;;
- -o|--output)
+ --output|-!(-*)o)
_filedir
return
;;
@@ -24,7 +29,7 @@ _iconv()
$split && return
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace
fi
} &&