jq icon indicating copy to clipboard operation
jq copied to clipboard

misleading statement in the manual

Open oguz-ismail opened this issue 4 years ago • 1 comments

The manual states:

jq has a few operators of the form a op= b, which are all equivalent to a |= . op b.

However this is not true; a op= b is not always equal to a |= . op b in function; more accurately it's equal to b as $rhs | a |= . op $rhs.

For instance, when the RHS of op= is a stream of n values, the result is also a stream of n values; in the same scenario |= . op yields a single value. Compare these:

$ jq -cn '.a += (1,2,3)'
{"a":1}
{"a":2}
{"a":3}
$
$ jq -cn '.a |= . + (1,2,3)'
{"a":1}

So, that statement is misleading.

oguz-ismail avatar May 08 '20 10:05 oguz-ismail

Yes, it should say they are equivalent to (b as $b | a |= . op $b).

emanuele6 avatar Oct 04 '23 17:10 emanuele6