diff options
Diffstat (limited to 'completions/iconv')
-rw-r--r-- | completions/iconv | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/completions/iconv b/completions/iconv index 81ae01b..bbcbbdd 100644 --- a/completions/iconv +++ b/completions/iconv @@ -1,38 +1,52 @@ # iconv(1) completion -*- shell-script -*- +# @since 2.12 +_comp_xfunc_iconv_compgen_charsets() +{ + _comp_cmd_iconv__compgen_charsets iconv +} + +# @deprecated 2.12 use `_comp_xfunc_iconv_compgen_charsets` instead _iconv_charsets() { - COMPREPLY+=($(compgen -X ... -W '$(${1:-iconv} -l | \ - command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur")) + _comp_compgen -ai iconv charsets "${1:-iconv}" +} + +_comp_cmd_iconv__compgen_charsets() +{ + _comp_compgen_split -X ... -- "$("$1" -l | + command sed -e 's@/*$@@' -e 's/[,()]//g')" } -_iconv() +_comp_cmd_iconv() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return + local noargopts='!(-*|*[fto]*)' + # shellcheck disable=SC2254 case $prev in --help | --usage | --version | --unicode-subst | --byte-subst | \ - --widechar-subst | -!(-*)[?V]) + --widechar-subst | -${noargopts}[?V]) return ;; - --from-code | --to-code | -!(-*)[ft]) - _iconv_charsets $1 + --from-code | --to-code | -${noargopts}[ft]) + _comp_cmd_iconv__compgen_charsets "$1" return ;; - --output | -!(-*)o) - _filedir + --output | -${noargopts}o) + _comp_compgen_filedir return ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && - complete -F _iconv -o default iconv + complete -F _comp_cmd_iconv -o default iconv # ex: filetype=sh |