mirror of
https://github.com/wader/fq.git
synced 2024-11-22 07:16:49 +03:00
interp: Output raw strings for stderr/0
Same as jq Also some cleanup and simplifications
This commit is contained in:
parent
9857323e5d
commit
f8bb502e2c
@ -25,20 +25,11 @@ def println: ., "\n" | print;
|
||||
def printerr: tostring | _stderr;
|
||||
def printerrln: ., "\n" | printerr;
|
||||
|
||||
def _debug($name):
|
||||
( (([$name, .] | tojson) | printerrln)
|
||||
, .
|
||||
);
|
||||
|
||||
# jq compat
|
||||
def debug: _debug("DEBUG");
|
||||
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 debug: (["DEBUG", .] | tojson | printerrln), .;
|
||||
def debug(f): (f | debug | empty), .;
|
||||
# output raw string or compact json to stderr and let input thru
|
||||
def stderr: printerr, .;
|
||||
|
||||
def _fatal_error($code): "error: \(.)\n" | halt_error($code);
|
||||
|
||||
|
4
pkg/interp/testdata/debug.fqtest
vendored
4
pkg/interp/testdata/debug.fqtest
vendored
@ -41,4 +41,6 @@ null
|
||||
"abc"
|
||||
"\n"
|
||||
stderr:
|
||||
null"\n"{"a":1}"\n""abc""\n"
|
||||
null
|
||||
{"a":1}
|
||||
abc
|
||||
|
Loading…
Reference in New Issue
Block a user