2001-04-02 13:53:06 +02:00
|
|
|
#compdef iconv
|
|
|
|
|
2004-06-17 15:12:25 +02:00
|
|
|
local expl curcontext="$curcontext" state line codeset ret=1
|
|
|
|
local LOCPATH="${LOCPATH:-/usr/lib/nls/loc}"
|
2001-04-02 13:53:06 +02:00
|
|
|
|
2002-03-15 17:26:08 +01:00
|
|
|
if _pick_variant gnu=GNU unix --version; then
|
2001-04-02 13:53:06 +02:00
|
|
|
|
2003-03-12 19:55:12 +01:00
|
|
|
local exargs="--list -? --help --usage --version -V"
|
|
|
|
_arguments -C -S -s \
|
|
|
|
"(-f --from-code $exargs)"{-f+,--from-code=}'[specify code set of input file]:code set:->codeset' \
|
|
|
|
"(-t --to-code $exargs)"{-t+,--to-code=}'[specify code set for output]:code set:->codeset' \
|
|
|
|
'(- 1)--list[list all character code sets]' \
|
|
|
|
"($exargs)-c[omit invalid characters from output]" \
|
|
|
|
"(-o --output $exargs)"{-o+,--output=}'[specify output file]:output file:_files' \
|
|
|
|
"(-s --silent --verbose $exargs)"{-s,--silent}'[suppress warnings]' \
|
|
|
|
"(-s --silent $exargs)--verbose[print progress information]" \
|
|
|
|
'(-)'{-\?,--help}'[display help information]' \
|
|
|
|
'(-)--usage[display a short usage message]' \
|
|
|
|
'(-)'{-V,--version}'[print program version]' \
|
|
|
|
'1:input file:_files' && return 0
|
2004-06-17 15:12:25 +02:00
|
|
|
|
|
|
|
if [[ $state = codeset ]]; then
|
|
|
|
if compset -P '*/'; then
|
|
|
|
_wanted option expl option compadd "$@" /TRANSLIT && ret=0
|
|
|
|
else
|
|
|
|
_wanted codesets expl 'code set' compadd "$@" \
|
|
|
|
-M 'm:{a-zA-Z}={A-Za-z} r:|-=* r:|=*' \
|
|
|
|
${${${(f)"$(_call_program codesets iconv --list|sed -n '/^$/,$ p')"}## #}%//} && ret=0
|
2001-04-02 13:53:06 +02:00
|
|
|
fi
|
2004-06-17 15:12:25 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
return ret
|
2001-04-02 13:53:06 +02:00
|
|
|
else
|
|
|
|
|
|
|
|
_arguments -C \
|
|
|
|
'-f[specify code set of input file]:code set:->codeset' \
|
|
|
|
'-t[specify code set for output]:code set:->codeset' \
|
|
|
|
'1:file:_files' && return 0
|
|
|
|
|
2004-06-17 15:12:25 +02:00
|
|
|
if [[ $state = codeset ]]; then
|
|
|
|
if [[ -f /usr/lib/iconv/iconv_data ]]; then # IRIX & Solaris
|
|
|
|
codeset=( ${${(f)"$(</usr/lib/iconv/iconv_data)"}%%[[:blank:]]*} )
|
|
|
|
elif [[ -d $LOCPATH/iconv ]]; then # OSF
|
|
|
|
codeset=( $LOCPATH/iconv/*(N:t) )
|
|
|
|
codeset=( ${(j:_:s:_:)codeset} )
|
|
|
|
else
|
|
|
|
return 1
|
2001-04-02 13:53:06 +02:00
|
|
|
fi
|
|
|
|
|
2004-06-17 15:12:25 +02:00
|
|
|
_wanted codesets expl 'code set' compadd "$@" -a codeset
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|