_parse_help: Re-fix --foo[=bar] handling.
This commit is contained in:
parent
3a39ac6676
commit
7b60fc6555
@ -754,11 +754,11 @@ _parse_help()
|
||||
gsub("[,/]", " ");
|
||||
x = -1;
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if (sub("^(--.[^<[]*)", "&", $i)) { x = i ; break }
|
||||
if ($i ~ /^--[^-]/) { x = i ; break }
|
||||
if ($i !~ /^-/) { break }
|
||||
}
|
||||
if (x == -1) { x = 1 }
|
||||
sub("=.*", "", $x);
|
||||
sub("[=<[].*", "", $x);
|
||||
print $x
|
||||
}'
|
||||
}
|
||||
|
@ -73,5 +73,13 @@ set cmd {fn() { printf '%s\n' "-f, -F, --foo"; }; _parse_help fn}
|
||||
assert_bash_list "--foo" $cmd "short + short + long"
|
||||
sync_after_int
|
||||
|
||||
set cmd {fn() { printf '%s\n' "--foo[=bar]"; }; _parse_help fn}
|
||||
assert_bash_list "--foo" $cmd "long with value and eq sign in brackets"
|
||||
sync_after_int
|
||||
|
||||
set cmd {fn() { printf '%s\n' "--foo=<bar>"; }; _parse_help fn}
|
||||
assert_bash_list "--foo" $cmd "long with value in angle brackets"
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
||||
|
Loading…
x
Reference in New Issue
Block a user