Add options --rawfd and --slurpfd#3546
Open
howtonotwin wants to merge 5 commits into
Open
Conversation
These allow jq to read data from files that might not have names, make it easier for shell scripts that use jq to avoid races, etc., without resorting to tricks like /dev/fd or /proc/self/fd that might not always be available (and don't quite behave the same). These options are otherwise very similar to --rawfile and --slurpfile and share most of their code.
Author
|
These options do work on Windows, but Windows programs that use FDs are subject to the restriction that programs with incompatible C runtimes can't inherit FDs from each other. The If I use a native Windows (MSVCRT/UCRT) binary like busybox> ./jq -n '{$foo, $bar}' 8<tests/modules/data.json 9<>tests/modules/data.json --slurpfd foo 8 --rawfd bar 9
{
"foo": [
{
"this": "is a test",
"that": "is too"
}
],
"bar": "{\n \"this\": \"is a test\",\n \"that\": \"is too\"\n}\n"
}So my questions are
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These allow jq to read data from files that might not have names, make it easier for shell scripts that use jq to avoid races, etc., without resorting to tricks like
/dev/fdor/proc/self/fdthat might not always be available (and don't quite behave the same). These options are otherwise very similar to--rawfileand--slurpfileand share most of their code.I'm using this on (GNU/)Linux. I'd appreciate feedback about/testing on other platforms. I didn't find a contributors' guidelines file or a style guide, so please tell me if I should do something differently!