1
1
mirror of https://github.com/wader/fq.git synced 2024-11-22 07:16:49 +03:00

Merge pull request #1015 from wader/stderr-raw-string

interp: Output raw strings for stderr/0
This commit is contained in:
Mattias Wadman 2024-09-24 12:53:11 +02:00 committed by GitHub
commit 8155a9cd27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 14 deletions

View File

@ -25,20 +25,11 @@ def println: ., "\n" | print;
def printerr: tostring | _stderr; def printerr: tostring | _stderr;
def printerrln: ., "\n" | printerr; def printerrln: ., "\n" | printerr;
def _debug($name):
( (([$name, .] | tojson) | printerrln)
, .
);
# jq compat # jq compat
def debug: _debug("DEBUG"); def debug: (["DEBUG", .] | tojson | printerrln), .;
def debug(f): . as $c | f | debug | $c; def debug(f): (f | debug | empty), .;
# output raw string or compact json to stderr and let input thru
# jq compat, output to compact json to stderr and let input thru def stderr: printerr, .;
def stderr:
( (tojson | printerr)
, .
);
def _fatal_error($code): "error: \(.)\n" | halt_error($code); def _fatal_error($code): "error: \(.)\n" | halt_error($code);

View File

@ -41,4 +41,6 @@ null
"abc" "abc"
"\n" "\n"
stderr: stderr:
null"\n"{"a":1}"\n""abc""\n" null
{"a":1}
abc