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

PATCH: more _long_options



A few fixes I needed to get _long_options to work with _tar.

--- /temp/pws/zsh-3.1.5/Completion/User/_long_options.bak	Mon Mar  8 14:29:04 1999
+++ /temp/pws/zsh-3.1.5/Completion/User/_long_options	Mon Mar  8 14:29:08 1999
@@ -42,14 +42,16 @@
 
 group=()
 expl=()
-while getopts "J:V:X:t" opt; do
-  case "$opt" in
-  [JV]) group=("-$opt" "$OPTARG");;
-  X)    expl=(-X "$OPTARG");;
-  t)    test=yes;;
-  esac
-done
-shift OPTIND-1
+if [[ $1 = -*~--* ]]; then
+  while getopts "J:V:X:t" opt; do
+    case "$opt" in
+      [JV]) group=("-$opt" "$OPTARG");;
+      X)    expl=(-X "$OPTARG");;
+      t)    test=yes;;
+    esac
+  done
+  shift OPTIND-1
+fi
 
 # Test if we are completing after `--' if we were asked to do so.
 
@@ -92,7 +94,7 @@
   # use the positional parameters we were given and a few standard
   # ones. Then we loop through this table.
 
-  set "$@" '*=FILE*' '_files' '*=(DIR|PATH)*' '_files -/' '*' ''
+  set -- "$@" '*=FILE*' '_files' '*=(DIR|PATH)*' '_files -/' '*' ''
 
   while [[ $# -gt 1 ]]; do
 
@@ -107,8 +109,8 @@
     # list we have built. If no option matches the pattern, we
     # continue with the next.
 
-    tmp=("${(@M)opts:#$~pattern}")
-    opts=("${(@)opts:#$~pattern}")
+    tmp=("${(@M)opts:##$~pattern}")
+    opts=("${(@)opts:##$~pattern}")
 
     (( $#tmp )) || continue
 

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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