[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-157-g10cfd72
Ville Skyttä
ville.skytta at iki.fi
Fri Apr 29 09:44:01 UTC 2011
The following commit has been merged in the master branch:
commit b6cdacf1f9857163d6bc5b2ba58e8277e562abcd
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Fri Apr 29 11:47:48 2011 +0300
_parse_help: Expand --[no]foo to --foo and --nofoo.
diff --git a/bash_completion b/bash_completion
index ae20dc0..079497a 100644
--- a/bash_completion
+++ b/bash_completion
@@ -759,8 +759,18 @@ _parse_help()
if ($i !~ /^-/) { break }
}
if (x == -1) { x = 1 }
- sub("[=<{[].*", "", $x);
- print $x
+ if ($x ~ /^--?[[]no[]]./) {
+ y = $x ; sub("[[]no[]]", "", y)
+ z = $x ; sub("[[]no[]]", "no", z)
+ sub("[=<{[].*", "", y)
+ sub("[=<{[].*", "", z)
+ print y
+ print z
+ }
+ else {
+ sub("[=<{[].*", "", $x)
+ print $x
+ }
}'
}
diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp
index 6be5afb..64709c6 100644
--- a/test/unit/_parse_help.exp
+++ b/test/unit/_parse_help.exp
@@ -89,5 +89,9 @@ set cmd {fn() { printf '%s\n' "--foo={bar,quux}"; }; _parse_help fn}
assert_bash_list "--foo" $cmd "long with value in curly brackets"
sync_after_int
+set cmd {fn() { printf '%s\n' "--[no]foo"; }; _parse_help fn}
+assert_bash_list "--foo\n--nofoo" $cmd "long with \[no\]"
+sync_after_int
+
teardown
--
bash-completion
More information about the Bash-completion-commits
mailing list