jq icon indicating copy to clipboard operation
jq copied to clipboard

Fix `--indent 0` implicitly enabling compact-output

Open amarshall opened this issue 4 years ago • 7 comments

Now it will retain pretty-printing, just removing any indentation. See also https://github.com/stedolan/jq/issues/1465.

amarshall avatar Jan 26 '21 23:01 amarshall

Coverage Status

Coverage increased (+0.4%) to 84.509% when pulling bedc1ff9bee5e99963486bf687077ca3663a8124 on amarshall:fix-indent-zero into 80052e5275ae8c45b20411eecdd49c945a64a412 on stedolan:master.

coveralls avatar Jan 27 '21 02:01 coveralls

@itchyny I would argue this is a bug fix, not a feature request. The manpage doesn’t document the prior behavior, and --indent 0 behaves completely differently from any other value. That said, I understand someone, somewhere might be relying on the prior functionality. Ultimately it’s the decision of maintainers, I don’t mind either way.

amarshall avatar Jul 26 '23 15:07 amarshall

Okay, rebase this PR, please. Also tests are needed.

itchyny avatar Jul 31 '23 11:07 itchyny

Hmm, how do I approve the actions to run on this PR?

nicowilliams avatar Jan 16 '24 22:01 nicowilliams

@nicowilliams i'm guessing it needs a new push to run

wader avatar Jan 16 '24 22:01 wader

Seems to break --indent 1

$ ./jq --indent 0 -n '[{a:1}]'
[
{
"a": 1
}
]
$ ./jq --indent 1 -n '[{a:1}]'
[{"a":1}]
$ ./jq --indent 2 -n '[{a:1}]'
[
  {
    "a": 1
  }
]

Maybe this is also an indication we should have some tests for indent/compact flags?

wader avatar Jan 25 '24 21:01 wader