From 4ebd21e1ebcac6f59b0ed1ea09f56385756f268c Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Tue, 3 Oct 2023 04:39:42 +0200 Subject: 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 --- tests/shtest | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3