Re: [dev] stderr: unnecessary?

From: Kris Maglione <maglione.k_AT_gmail.com>
Date: Fri, 11 Jun 2010 00:13:36 -0400

On Thu, Jun 10, 2010 at 11:02:08PM -0500, Matthew Bauer wrote:
>No, I just don't understand why you need a stderr when you have a stdout.
>Couldn't you just print your error to stdout?

On the (probably bad) assumption that you're not a troll, I'll
answer the question.

Yes, you can print errors to stdout. No, it's not a good idea.
We use pipes extensively on unix, and we tend to have
expectations of what will be coming through the standard output.
When grep can't open one of its input files, or sed decides a
command is garbled, we can't make programmatic use of that
output. Moreover, if we're piping the output to another program,
we probably want to see the error on the console. Or maybe we
just want to ignore it altogether.

%grep -n '^foo(' bar.c baz.c >locations.txt

%loc=$(which foo 2>/dev/null) || exit 1

-- 
Kris Maglione
A program is portable to the extent that it can be easily moved to a
new computing environment with much less effort than would be required
to write it afresh.
	--W. Stan Brown
Received on Fri Jun 11 2010 - 04:13:36 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 11 2010 - 04:24:01 UTC