about summary refs log tree commit diff
path: root/Completion/User/_iconv
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-03-11 22:53:41 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-03-11 22:53:41 +0000
commite264c1bee199acd99267e2142ab22507cadb488a (patch)
treeaf471605f1dafb99214a91b44dedd17f350ae703 /Completion/User/_iconv
parentc140245164e0448685940f17fd8efcbc8109b237 (diff)
downloadzsh-e264c1bee199acd99267e2142ab22507cadb488a.tar.gz
zsh-e264c1bee199acd99267e2142ab22507cadb488a.tar.xz
zsh-e264c1bee199acd99267e2142ab22507cadb488a.zip
Various new, improved, fixed or updated functions (13600)
Diffstat (limited to 'Completion/User/_iconv')
-rw-r--r--Completion/User/_iconv54
1 files changed, 54 insertions, 0 deletions
diff --git a/Completion/User/_iconv b/Completion/User/_iconv
new file mode 100644
index 000000000..1e21b9655
--- /dev/null
+++ b/Completion/User/_iconv
@@ -0,0 +1,54 @@
+#compdef iconv
+
+local expl curcontext="$curcontext" state line codeset LOCPATH
+
+(( $+_is_gnu )) || typeset -gA _is_gnu
+if (( ! $+_is_gnu[$words[1]] )); then
+  if [[ $(_call version $words[1] --version </dev/null 2>/dev/null) = *GNU* ]]; 
+  then
+    _is_gnu[$words[1]]=yes
+  else
+    _is_gnu[$words[1]]=
+  fi
+fi
+
+if [[ -n "$_is_gnu[$words[1]]" ]]; then
+
+  _arguments -C \
+    {'(--from-code --list)-f','(-f --list)--from-code='}'[specify code set of input file]:code set:->codeset' \
+    {'(--to-code --list)-t','(-t --list)--to-code='}'[specify code set for output]:code set:->codeset' \
+    '--list[list all character code sets]' \
+    '--verbose[print progress information]' \
+    {'(--help)-\?','(-\?)--help'}'[display help information]' \
+    '--usage[display a short usage message]' \
+    {'(--version)-V','(-V)--version'}'[print program version]' \
+    '1:file:_files' && return 0
+    
+    if [[ $state = codeset ]]; then
+      _wanted codesets expl 'code set' \
+          compadd "$@" ${${(s:,:)$(iconv --list|sed -n '/^$/,$ p')}## #}
+    fi
+    
+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
+
+    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:=/usr/lib/nls/loc}/iconv ]]; then  # OSF
+	codeset=( $LOCPATH/iconv/*(N:t) )
+	codeset=( ${(j:_:s:_:)codeset} )
+      else
+	return 1
+      fi
+	
+      _wanted codesets expl 'code set' compadd "$@" -a codeset
+    fi
+
+fi    
+    
+