diff --git a/pkg/interp/internal.jq b/pkg/interp/internal.jq index 48435959..a929ed41 100644 --- a/pkg/interp/internal.jq +++ b/pkg/interp/internal.jq @@ -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); diff --git a/pkg/interp/testdata/debug.fqtest b/pkg/interp/testdata/debug.fqtest index e0766092..d7e26aed 100644 --- a/pkg/interp/testdata/debug.fqtest +++ b/pkg/interp/testdata/debug.fqtest @@ -41,4 +41,6 @@ null "abc" "\n" stderr: -null"\n"{"a":1}"\n""abc""\n" \ No newline at end of file +null +{"a":1} +abc