diff --git a/docs/content/manual/manual.yml b/docs/content/manual/manual.yml index 442fc0d4f1..849692e11c 100644 --- a/docs/content/manual/manual.yml +++ b/docs/content/manual/manual.yml @@ -2984,6 +2984,17 @@ sections: `["DEBUG:", ]` and prints that and a newline on stderr, compactly. This may change in the future. + - title: "`debug(msg)`" + body: | + + Calls `debug/0` to print the debug `msg` to stderr, but this + version sends stdin to stdout without consuming it. + + examples: + - program: 'debug("here1") | . + 1' + input: '1' + output: ['2'] + - title: "`stderr`" body: | diff --git a/src/builtin.jq b/src/builtin.jq index a102fd51a0..87ac6976d6 100644 --- a/src/builtin.jq +++ b/src/builtin.jq @@ -1,5 +1,6 @@ def halt_error: halt_error(5); def error(msg): msg|error; +def debug(msg): . as $dot | msg | debug | $dot else . end; def map(f): [.[] | f]; def select(f): if f then . else empty end; def sort_by(f): _sort_by_impl(map([f]));