_parse_help: Expand --[no]foo to --foo and --nofoo.

This commit is contained in:
Ville Skyttä 2011-04-29 11:47:48 +03:00
parent 1709686b7e
commit b6cdacf1f9
2 changed files with 16 additions and 2 deletions

View File

@ -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
}
}'
}

View File

@ -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