about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-11-17 10:37:37 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-11-17 10:37:37 +0000
commit0662164f13dc1df9ca2cdf1b5ab78d297eed51d1 (patch)
treef95a795001e9073b927d89df5ecf19c45313f674
parent85c513894d42293c79b46f09a039162329698656 (diff)
downloadzsh-0662164f13dc1df9ca2cdf1b5ab78d297eed51d1.tar.gz
zsh-0662164f13dc1df9ca2cdf1b5ab78d297eed51d1.tar.xz
zsh-0662164f13dc1df9ca2cdf1b5ab78d297eed51d1.zip
26053: handle --help output like "--[fetch]all"
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Base/Utility/_arguments17
2 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9fe8c2bca..c2bb184ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-17  Peter Stephenson  <pws@csr.com>
+
+	* 26053: Completion/Base/Utility/_arguments: handle
+	"<cmd> --help" output that includes optional parts of options
+	in square brackets.
+
 2008-11-15  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 26047: Src/pattern.c, Src/Zle/comp.h, Src/Zle/compmatch.c,
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index 21c1541fb..126d9c315 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -5,7 +5,7 @@
 
 local long cmd="$words[1]" descr odescr mesg subopts opt opt2 usecc autod
 local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt
-local setnormarg
+local setnormarg start rest
 local -a match mbegin mend
 
 long=$argv[(I)--]
@@ -97,10 +97,19 @@ if (( long )); then
        # present.  Maybe the problem was that the intervening code
        # didn't.  If it's buggy without removing them, the problem
        # probably is later, not here.
-       if [[ -z ${tmp[(r)${match[1]%%[^a-zA-Z0-9_-]#}]} ]]; then
-	 tmp+=($match[1])
+       start=${match[1]}
+       rest=${match[2]}
+       if [[ -z ${tmp[(r)${start%%[^a-zA-Z0-9_-]#}]} ]]; then
+	 # variant syntax seen in fetchmail:
+	 # --[fetch]all  means --fetchall or --all.
+	 # maybe needs to be more general
+	 if [[ $start = (#b)(*)\[(*)\](*) ]]; then
+	   tmp+=("${match[1]}${match[2]}${match[3]}" "${match[1]}${match[3]}")
+	 else
+	   tmp+=($start)
+	 fi
        fi
-       opt=$match[2]
+       opt=$rest
      done
      # If there's left over text, assume it's a description; it
      # may be truncated but if it's too long it's no use anyway.