Skip to content

Commit

Permalink
Merge pull request #1015 from wader/stderr-raw-string
Browse files Browse the repository at this point in the history
interp: Output raw strings for stderr/0
  • Loading branch information
wader authored Sep 24, 2024
2 parents 9857323 + f8bb502 commit 8155a9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 4 additions & 13 deletions pkg/interp/internal.jq
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion pkg/interp/testdata/debug.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ null
"abc"
"\n"
stderr:
null"\n"{"a":1}"\n""abc""\n"
null
{"a":1}
abc

0 comments on commit 8155a9c

Please sign in to comment.