Repository navigation
add jq CLI surface parity for output, streaming, seq, and modules - #768
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b8b9e37d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| func newJQInputIter(ctx context.Context, inv *commands.Invocation, opts *jqOptions, inputs []string) (*jqSliceIter, error) { | ||
| sources, err := readJQInputSources(ctx, inv, inputs) |
There was a problem hiding this comment.
Stop eagerly reading stdin when building the iterator
newJQInputIter unconditionally calls readJQInputSources, and readJQInputSources immediately reads all stdin when no file args are provided. This makes commands like jq -n '1' consume/block on stdin even though the filter does not require input, and it also prevents early-terminating input/inputs filters from short-circuiting on long-lived streams. Input consumption needs to be lazy so stdin is only read when the jq program actually requests it.
Useful? React with 👍 / 👎.
| if name != "" && (len(inputs) > 0 || !opts.nullInput) { | ||
| return name |
There was a problem hiding this comment.
Return stdin filename for input_filename under -n
The input_filename callback returns nil whenever -n is set and there are no explicit file operands because of the len(inputs) > 0 || !opts.nullInput guard. In jq, jq -n 'inputs | input_filename' should yield "<stdin>" for stdin-fed values, so this condition causes incorrect results for null-input workflows that still consume data via inputs/input.
Useful? React with 👍 / 👎.
What changed
-V,--ascii-output,-C/--color-output,-M/--monochrome-output,--unbuffered,--stream,--stream-errors,--seq,-L/--library-path, and--build-configurationinputs, andinput_filename-Land module-relativesearchmetadataWhy
The gbash jq wrapper only covered a narrow subset of jq's CLI surface, so the compatibility suite stayed green while several standard jq flags and input modes were still missing.
Impact
contrib/jqnow matches jq 1.8.1 behavior across the planned CLI flags and input modes, while still keeping the legacy gbash aliases-v,--ascii,--color, and--monochromeavailable.Root cause
The previous implementation compiled gojq with variables and environment only, formatted output through
gojq.Marshal, and did not provide a sandbox-aware module loader or jq-style input iterator plumbing.Validation
make lintgo test ./contrib/jqGBASH_RUN_JQ_CONFORMANCE=1 GBASH_CONFORMANCE_JQ="$(./scripts/ensure-jq.sh)" GBASH_CONFORMANCE_BASH="$(./scripts/ensure-bash.sh)" go test ./contrib/jq -run '^TestJQConformance$' -count=1Remaining known gap
xfail