Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated --nul-output documentation #2535

Closed
wants to merge 1 commit into from

Conversation

peter-dolkens
Copy link

--nul-output / -0 was removed RE: #1271 and #2350

This updates the documentation so one doesn't go crazy trying to figure out why it's not working 😂

`--nul-output` / `-0` was removed RE: jqlang#1271 and jqlang#2350
@peter-dolkens peter-dolkens changed the title Remove deprecated --nul-output documentation Remove deprecated --nul-output documentation Feb 3, 2023
@wader
Copy link
Member

wader commented Feb 5, 2023

Hi, what version is this? with jq master i see this.

$ jq --version
jq-1.6-159-gcff5336

$ jq -n --nul-output '1,2,3' | hexdump -C
00000000  31 00 32 00 33 00                                 |1.2.3.|
00000006

$ jq -n --null-output '1,2,3' | hexdump -C
jq: Unknown option --null-output
Use jq --help for help with command-line options,
or see the jq manpage, or online docs  at https://stedolan.github.io/jq

# -0 treated as number
$ jq -n -0 '1,2,3' | hexdump -C
00000000  2d 30 0a                                          |-0.|
00000003

Confusd, so #1271 was not reverted? and -0 was not added?

@peter-dolkens
Copy link
Author

Sorry if I was mistaken. I'm running on M2 Macbook Air

➜  ~ jq --version
jq-1.6
➜  ~ jq --help
jq - commandline JSON processor [version 1.6]

Usage:  jq [options] <jq filter> [file...]
        jq [options] --args <jq filter> [strings...]
        jq [options] --jsonargs <jq filter> [JSON_TEXTS...]

jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.

The simplest filter is ., which copies jq's input to its output
unmodified (except for formatting, but note that IEEE754 is used
for number representation internally, with all that that implies).

For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq

Example:

        $ echo '{"foo": 0}' | jq .
        {
                "foo": 0
        }

Some of the options include:
  -c               compact instead of pretty-printed output;
  -n               use `null` as the single input value;
  -e               set the exit status code based on the output;
  -s               read (slurp) all inputs into an array; apply filter to it;
  -r               output raw strings, not JSON texts;
  -R               read raw strings, not JSON texts;
  -C               colorize JSON;
  -M               monochrome (don't colorize JSON);
  -S               sort keys of objects on output;
  --tab            use tabs for indentation;
  --arg a v        set variable $a to value <v>;
  --argjson a v    set variable $a to JSON value <v>;
  --slurpfile a f  set variable $a to an array of JSON texts read from <f>;
  --rawfile a f    set variable $a to a string consisting of the contents of <f>;
  --args           remaining arguments are string arguments, not files;
  --jsonargs       remaining arguments are JSON arguments, not files;
  --               terminates argument processing;

Named arguments are also available as $ARGS.named[], while
positional arguments are available as $ARGS.positional[].

See the manpage for more options.
➜  ~

I assumed from the issues linked above that this functionality had been reverted, as it is in documentation, but not in the latest official release as far as I could tell.

@pkoppstein
Copy link
Contributor

Unfortunately, the versioning information on the online documentation is not always exactly correct.

@wader
Copy link
Member

wader commented Feb 7, 2023

@peter-dolkens No worries, i'm confused also what the state of master is. Looking at the code in master https://github.com/stedolan/jq/blob/master/src/main.c#L402 seems like -0 and --nul-output is there... but -0 is broken for some reason, i get a feeling it ends up here https://github.com/stedolan/jq/blob/master/src/main.c#L325 as isoptish check if the option isalpha. But not sure it's a good idea to allow -0 as it's a bit ambigous.

@peter-dolkens
Copy link
Author

For what it's worth - whilst I understand the reasoning behind the discussions I linked - I'd still support -0 and similar options.

The challenge I was trying to solve was I had a collection of "json-like" blobs serialized in a larger json object.

I was trying to output them raw using -r which worked fine, but then I wanted to run them through hjson or similar to sanitize them. Unfortunately I was struggling to find a separator that I could use to pass to xargs to achieve this as -0 wasn't working, and the blobs contained new lines themselves.

I personally don't think the security argument holds much weight, as ultimately it's not the parsing or separator that's causing the security vulnerability, but rather their use on unsanitized/unverified inputs. Javascript has eval, Dotnet has Assembly.Load, Typescript has require - these aren't security vulnerabilities - it's the use of these features that may constitute a vulnerability.

@itchyny
Copy link
Contributor

itchyny commented Jun 4, 2023

Ref: #2235.

@itchyny
Copy link
Contributor

itchyny commented Jun 6, 2023

Now that #2235 is merged to the master branch, I think the master version fully support what is written in the development version of documentation. Note (again) that this option is written in the development version document not 1.6, and will be shipped in the next version.

@itchyny itchyny closed this Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants