Parse short options in order given

Fixes:
* Short options cannot be repeated in the same group:
  e.g., `-nn` fails, but `--null-input --null-input` works
* Short options are processed in an arbitrary fixed order, not the order
  given by the user: e.g., `-hV`, `-Vh`, `-h -V`, and `--help --version`
  are processed as `-h`, but `-V -h` and `--version --help` are
  processed as `-V`
* `-L` cannot be a part of a short option group (as the last one):
  e.g., `-nLlib` and `-nL lib` fail
This commit is contained in:
Thalia Archibald authored and Emanuele Torre committed 2024-11-08 19:07:55 +01:00
1 parent 562d5c5222
commit ff4acba769
2 files changed
+193 -225

No files matched your search

+22
View File
@@ -210,6 +210,28 @@ else
cmp $d/out $d/expected
fi
# Regression tests for #3194
echo 42 > $d/expected
$JQ -nn 42 > $d/out 2>&1
cmp $d/out $d/expected
$JQ -nL. 42 > $d/out 2>&1
cmp $d/out $d/expected
$JQ -nL . 42 > $d/out 2>&1
cmp $d/out $d/expected
$JQ -h > $d/expected 2>&1
$JQ -hV > $d/out 2>&1
cmp $d/out $d/expected
$JQ -h -V > $d/out 2>&1
cmp $d/out $d/expected
$JQ -V > $d/expected 2>&1
$JQ -Vh > $d/out 2>&1
cmp $d/out $d/expected
$JQ -V -h > $d/out 2>&1
cmp $d/out $d/expected
## Test streaming parser
## If we add an option to stream to the `import ... as $symbol;` directive