-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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.