From 2d5dd747324b130e8aeea6fa9c274ead18b62ef6 Mon Sep 17 00:00:00 2001 From: m0viefreak Date: Tue, 6 Sep 2016 22:35:26 -0700 Subject: 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. --- Completion/Base/Utility/_arguments | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Completion/Base') 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 -- cgit 1.4.1