mirror of
https://github.com/wader/fq.git
synced 2024-12-28 08:02:28 +03:00
Merge pull request #58 from wader/stderr-and-tests
interp: Add stderr again for jq compat
This commit is contained in:
commit
6cbd6f6b79
@ -9,11 +9,17 @@ def println: ., "\n" | print;
|
||||
def printerr: tostring | _stderr;
|
||||
def printerrln: ., "\n" | printerr;
|
||||
|
||||
# jq compat
|
||||
def debug:
|
||||
( ((["DEBUG", .] | tojson) | printerrln)
|
||||
, .
|
||||
);
|
||||
def debug(f): . as $c | f | debug | $c;
|
||||
# jq compat, output to compact json to stderr and let input thru
|
||||
def stderr:
|
||||
( (tojson | printerr)
|
||||
, .
|
||||
);
|
||||
|
||||
def _global_var($k): _global_state[$k];
|
||||
def _global_var($k; f): _global_state(_global_state | .[$k] |= f) | .[$k];
|
||||
|
29
pkg/interp/testdata/debug.fqtest
vendored
29
pkg/interp/testdata/debug.fqtest
vendored
@ -13,3 +13,32 @@ null> ^D
|
||||
stderr:
|
||||
["DEBUG",{"a":123,"b":[]}]
|
||||
["DEBUG",{"a":123}]
|
||||
$ fq -n 'null, {a:1}, "abc" | ., "\n" | print'
|
||||
null
|
||||
{"a":1}
|
||||
abc
|
||||
$ fq -n 'null, {a:1}, "abc" | println'
|
||||
null
|
||||
{"a":1}
|
||||
abc
|
||||
$ fq -n 'null, {a:1}, "abc" | ., "\n" | printerr'
|
||||
stderr:
|
||||
null
|
||||
{"a":1}
|
||||
abc
|
||||
$ fq -n 'null, {a:1}, "abc" | printerrln'
|
||||
stderr:
|
||||
null
|
||||
{"a":1}
|
||||
abc
|
||||
$ fq -n 'null, {a:1}, "abc" | ., "\n" | stderr'
|
||||
null
|
||||
"\n"
|
||||
{
|
||||
"a": 1
|
||||
}
|
||||
"\n"
|
||||
"abc"
|
||||
"\n"
|
||||
stderr:
|
||||
null"\n"{"a":1}"\n""abc""\n"
|
Loading…
Reference in New Issue
Block a user