"Derrick Stolee via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > The existing test_subcommand method requires an exact list of arguments > for the subcommand. This is too rigid for our needs here, so create a > new method, test_subcommand_flex. Use it to check that the > --full-name-hash option is passing through. This is something I found need for in the past at least a few times. > +# Check that the given subcommand was run with the given set of > +# arguments in order (but with possible extra arguments). > +# > +# test_subcommand_flex [!] <command> <args>... < <trace> > +# > +# If the first parameter passed is !, this instead checks that > +# the given command was not called. > +# > +test_subcommand_flex () { > + local negate= > + if test "$1" = "!" > + then > + negate=t > + shift > + fi > + > + local expr="$(printf '"%s".*' "$@")" OK, so it works exactly like the comment said. You allow arbigrary garbage in between the given parameters that come in the order given. As long as this is used to make sure that the flags are passed through, by somebody who knows how the code constructs the command line, this should be fine, as we won't be permuting the command line parameters. Looking good. > + if test -n "$negate" > + then > + ! grep "\[$expr\]" > + else > + grep "\[$expr\]" > + fi > +} > + > # Check that the given command was invoked as part of the > # trace2-format trace on stdin. > #