_parse_help: Make work with pipe separated options.

This commit is contained in:
Ville Skyttä 2011-04-27 23:22:03 +03:00
parent fabbec105c
commit 9d810be86b
2 changed files with 5 additions and 1 deletions

View File

@ -752,7 +752,7 @@ _parse_help()
"$cmd" ${2:---help} 2>&1 | awk \
'{
if ($0 !~ /^[ \t]*-/) { next }
gsub("[,/]", " ");
gsub("[,/|]", " ");
x = -1;
for (i = 1; i <= NF; i++) {
if ($i ~ /^--[^-]/) { x = i ; break }

View File

@ -69,6 +69,10 @@ set cmd {fn() { printf '%s\n' "-T/--upload-file"; }; _parse_help fn}
assert_bash_list "--upload-file" $cmd "short + long, slash separated"
sync_after_int
set cmd {fn() { printf '%s\n' "-T|--upload-file"; }; _parse_help fn}
assert_bash_list "--upload-file" $cmd "pipe separated"
sync_after_int
set cmd {fn() { printf '%s\n' "-f, -F, --foo"; }; _parse_help fn}
assert_bash_list "--foo" $cmd "short + short + long"
sync_after_int