Although useful for in-tree debugging, the ./nbdkit script was not very nice when it comes to using the '--longopt=value' single-string form of options, compared to the two-string '--longopt value' form. Since we used a glob for the multiple spellings of --exportname and --pidfile, the script would try to treat the next argument literally instead of recognizing that the argument was already consumed. Likewise, the script was not recognizing '--filter=foo'.
Since the script already relies on bash, we can exploit bash's case fallthrough (using ';&' instead of ';;'), to rewrite inline --filter=foo without having to duplicate logic. This does NOT try to honor option abbreviations. If you are testing that aspect of getopt_long, don't use this script ;) Signed-off-by: Eric Blake <[email protected]> --- I'm pushing this one now, as it tripped me up during testing. nbdkit.in | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nbdkit.in b/nbdkit.in index d1caf57..996616d 100644 --- a/nbdkit.in +++ b/nbdkit.in @@ -65,6 +65,11 @@ verbose= while [ $# -gt 0 ]; do case "$1" in # Flags that take an argument. We must not rewrite the argument. + # But make sure globs don't mishandle longopts with =. + --export*=* | --pid*=*) + args[$i]="$1" + shift + ;; -e | --export* | -g | --group | -i | --ip* | -P | --pid* | -p | --port | --run | --selinux-label | -t | --threads | --tls | --tls-certificates | -U | --unix | -u | --user) args[$i]="$1" ((++i)) @@ -80,6 +85,11 @@ while [ $# -gt 0 ]; do ;; # Filters can be rewritten if purely alphanumeric. + --filter=*) + tmp=${1#*=} + shift + set - --filter "$tmp" "$@" + ;& # fallthru --filter) args[$i]="--filter" ((++i)) -- 2.14.3 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
