Skip to content

Conversation

@thaliaarchi
Copy link
Contributor

@thaliaarchi thaliaarchi commented Sep 17, 2025

This is a further development on @christf's #3367 (feat: allow writing to output file), which handles some edge cases not considered.

Other uses of stdout, such as tests, fuzzers, disassembly, and debug traces, remain directed to stdout; only JSON values are written to the output file. Consequently, users of --debug-dump-disasm and --debug-trace can now separate the debug and JSON outputs. On Windows, the output file is marked as binary when --binary is passed.

This incorporates the commit from #3367, but with minor fixes squashed in.

Fixes #2418
Closes #3367

christf and others added 2 commits September 16, 2025 22:05
This allows to write the output to a file and introduces the options -o
and --output-file that take a filename as parameter. When not specifying
-o, stdout will be used for compatibility.

This will be helpful when calling jq inside a docker context as it means
jq will not have to be called from within a shell with output redirection.
To enable instantiating multiple VMs, instead pass ofile when needed.
There is only one use of jv_dump outside of tests, bytecode dumps, and
tracing; pass ofile to it.
When both --binary is given before --output-file, the file wasn't marked
as binary. When checking whether stdout is a TTY, it didn't handle
--output-file.
@thaliaarchi
Copy link
Contributor Author

Well that was a lot of back and forth with CI to identify the problem with Windows 😅. I'm confident in this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output to file without STDOUT redirection

3 participants