diff options
author | Emanuele Torre <torreemanuele6@gmail.com> | 2023-10-03 04:39:42 +0200 |
---|---|---|
committer | Nico Williams <nico@cryptonector.com> | 2023-10-04 00:00:46 -0500 |
commit | 4ebd21e1ebcac6f59b0ed1ea09f56385756f268c (patch) | |
tree | 674325b10323dae990841d4e7d84541e5a58acf1 /tests | |
parent | 7f547827e47b5ade563a293329deb4226496d72f (diff) |
Allow passing the inline jq script before --
jq previously only allowed passing the inline script before -- (as if
they were options) even though one would expect the inline script to be
a positional argument.
Since jq previously also refused to run with a usage error if the script
was passed after -- (It was not assuming . as script as it does when
no arguments are passed), and positional arguments are allowed before --
and even before other options, it should not be a breaking change to
change that weird behaviour, and allow the script to appear after --.
It also simplifies the option parsing code a bunch.
Fixes #2918
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/shtest | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/shtest b/tests/shtest index 8a7ba077..d854f3d9 100755 --- a/tests/shtest +++ b/tests/shtest @@ -579,4 +579,14 @@ if ( ! $msys && ! $mingw ) && locale -a > /dev/null; then fi fi +# Allow passing the inline jq script before -- #2919 +if ! r=$($JQ --args -rn -- '$ARGS.positional[0]' bar) || [ "$r" != bar ]; then + echo "passing the inline script after -- didn't work" + exit 1 +fi +if ! r=$($JQ --args -rn 1 -- '$ARGS.positional[0]' bar) || [ "$r" != 1 ]; then + echo "passing the inline script before -- didn't work" + exit 1 +fi + exit 0 |