about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
authorm0viefreak <m0viefreak.cm@googlemail.com>2016-09-06 22:35:26 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-09-06 22:35:26 -0700
commit2d5dd747324b130e8aeea6fa9c274ead18b62ef6 (patch)
tree412504d0ffcd07b5556b8284bccf9b0b9853a5b5 /Completion/Base
parent30bb9fe7b770304422a4958f76b0cec0b918a89a (diff)
downloadzsh-2d5dd747324b130e8aeea6fa9c274ead18b62ef6.tar.gz
zsh-2d5dd747324b130e8aeea6fa9c274ead18b62ef6.tar.xz
zsh-2d5dd747324b130e8aeea6fa9c274ead18b62ef6.zip
38153: change the way long options are examined for "=" signs to more accurately identify options that take arguments
Note in workers/39135:
The pattern in 266/268 appears to match the '=' sign even though it's in the
second colon-separated field, where it doesn't denote a mandatory argument.
I'm guessing the pattern match on lines 266/268 should be fixed ...

This commit alters those patterns in what is hoped to be the desired way.
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/Utility/_arguments22
1 files changed, 14 insertions, 8 deletions
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index 687c0c4ed..82c969629 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -105,7 +105,10 @@ if (( long )); then
 	 continue
        else
 	 # Still no comment, add the previous options anyway.
-	 lopts+=("${tmp[@]}")
+         # Add a ':' after the option anyways, to make the the matching of
+         # the options lateron work as intended.
+         # It will be removed again later.
+	 lopts+=("${^tmp[@]}":)
 	 tmp=()
        fi
      fi
@@ -147,7 +150,7 @@ if (( long )); then
    done
    # Tidy up any remaining uncommented options.
    if (( ${#tmp} )); then
-     lopts+=("${tmp[@]}")
+     lopts+=("${^tmp[@]}":)
    fi
 
     # Remove options also described by user-defined specs.
@@ -220,19 +223,22 @@ if (( long )); then
 
       # Ignore :descriptions at the ends of lopts for matching this;
       # they aren't in the patterns.
-      tmp=("${(@M)lopts:##$~pattern(|:*)}")
-      lopts=("${(@)lopts:##$~pattern(|:*)}")
+      tmp=("${(@M)lopts:##$~pattern:*}")
+      lopts=("${(@)lopts:##$~pattern:*}")
 
       (( $#tmp )) || continue
 
       opt=''
 
+      # Clean suffix ':' added earlier
+      tmp=("${(@)tmp%:}")
+
       # If there are option strings with a `[=', we take these to get an
       # optional argument.
 
-      tmpo=("${(@M)tmp:#*\[\=*}")
+      tmpo=("${(@M)tmp:#[^:]##\[\=*}")
       if (( $#tmpo )); then
-        tmp=("${(@)tmp:#*\[\=*}")
+        tmp=("${(@)tmp:#[^:]##\[\=*}")
 
 	for opt in "$tmpo[@]"; do
 	  # Look for --option:description and turn it into
@@ -263,9 +269,9 @@ if (( long )); then
       # Basically the same as the foregoing.
       # TODO: could they be combined?
 
-      tmpo=("${(@M)tmp:#*\=*}")
+      tmpo=("${(@M)tmp:#[^:]##\=*}")
       if (( $#tmpo )); then
-        tmp=("${(@)tmp:#*\=*}")
+        tmp=("${(@)tmp:#[^:]##\=*}")
 
 	for opt in "$tmpo[@]"; do
 	  if [[ $opt = (#b)(*):([^:]#) ]]; then