Skip to content

Future --raw-input0 and its slurping behaviour #3456

@01mf02

Description

@01mf02

First of all: happy new year, everybody! :)

@pjungkamp has worked on an addition to jaq that implements basically --raw-input0. This is very similar to --raw-input, but splitting on '\0' instead on '\n' / "\r\n". That allows for round-tripping --raw-output0.

The interesting question is what should happen in the case of --raw-input0 --slurp. I see two options what that could do:

a) yield the original string unchanged, like --raw-input --slurp, or
b) yield an array of \0-delimited strings, like --raw-input0 -n '[inputs]'

# option a)
$ printf "abc\0def\0" | jq --raw-input0 -s
"abc\u0000def\u0000"
# option b)
$ printf "abc\0def\0" | jq --raw-input0 -s
["abc", "def"]

For me, option b) seems to be more useful in practice, but potentially also more confusing, because it yields an array of strings, whereas --raw-input --slurp yields a string.

I'm asking this question to collect feedback and to make a choice that the jq team agrees with, in case that jq wishes to implement --from-input0 as well one day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions