Closed gpBlockchain closed 1 year ago
I suggested that in issue #288.
I could understand your confusion.
You must be had a misunderstanding with its literal meaning: "stderr
is used for errors only".
In fact, the stderr
is used for printing things which are not outputs, so users could use pipes easily.
That is a very traditional practice. There are lots examples in the real world.
For examples:
curl
(since 1996)
curl --verbose --location www.github.com >stdout.log 2>stderr.log
jq
(since 2012)
echo '{ "id": "yangby-cryptape", "age": 46, "hobby": ["drink coke", "play with dogs", "sleep"] }' \
| jq ".hobby[2] | debug" >stdout.log 2>stderr.log
Both curl
and jq
are very famous open-source projects, and they are started in different decades.
And they both use stdout
for outputs and stderr
for debug messages.
As a reference, I copied some documentation from jq
Manual.
... (Recall that a jq program's output values are always output as JSON texts on
stdout
.) ... Thestderr
builtin outputs its input in raw mode to stderr with no additional decoration, not even a newline. ... Causes adebug
message based on the input value to be produced. Thejq
executable wraps the input value with["DEBUG:", <input-value>]
and prints that and a newline onstderr
, compactly.
Feel free to @ me if you still feel confuse, or please close this issue.