Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#254801: zsh: iconv code set completion case insensitivity



Clint Adams wrote:
> > It doesn't with 4.1.1.  I'll try current in a bit.
> 
> % iconv -f <TAB>Usage: iconv [-c] [-s] [-f fromcode] [-t tocode] [file ...]

I don't quite understand why you got the usage message four times.

Anyway, can you try the following patch.

I've just noticed that the Sourceforge compile farm has Solaris
9 machines but their iconv is identical to that of Solaris 8. So we
probably need to just try running iconv -l.

Does /usr/lib/iconv/iconv_data exist? What are the -c and -s options -
the same as GNU iconv's?

Oliver

Index: Completion/Unix/Command/_iconv
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_iconv,v
retrieving revision 1.4
diff -u -r1.4 _iconv
--- Completion/Unix/Command/_iconv	17 Jun 2004 13:12:26 -0000	1.4
+++ Completion/Unix/Command/_iconv	25 Jun 2004 09:26:07 -0000
@@ -1,9 +1,10 @@
 #compdef iconv
 
 local expl curcontext="$curcontext" state line codeset ret=1
+local -a args
 local LOCPATH="${LOCPATH:-/usr/lib/nls/loc}"
 
-if _pick_variant gnu=GNU unix --version; then
+if _pick_variant gnu=GNU unix --version 2>/dev/null; then
 
   local exargs="--list -? --help --usage --version -V"
   _arguments -C -S -s \
@@ -31,14 +32,18 @@
 
   return ret
 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
+  [[ $OSTYPE = solaris2.9 ]] &&
+      args=( '(-l)'{-c,-s} '(- 1)-l[list available code sets]' )
+  
+  _arguments -C $args \
+    '(-l)-f[specify code set of input file]:code set:->codeset' \
+    '(-l)-t[specify code set for output]:code set:->codeset' \
+    '(-l)1:file:_files' && return 0
 
   if [[ $state = codeset ]]; then
-    if [[ -f /usr/lib/iconv/iconv_data ]]; then  # IRIX & Solaris
+    if [[ $OSTYPE = solaris2.9 ]]; then
+      codeset=( $(_call_program codesets iconv -l) )
+    elif [[ -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) )



Messages sorted by: Reverse Date, Date, Thread, Author