Re: printf "hi\000"|egrep hi #why no STDERR output
In article <slrng0rv84.7t9.stephane.chazelas@spam.is.invalid> ,
Stephane CHAZELAS <this.address@is.invalid> wrote:
>2008-04-22, 14:44(+00), Kenny McCormack:
>[...]
>>>> ~ $ printf "hi\000"|egrep hi >foo
>>>> ~ $ cat foo
>>>> Binary file (standard input) matches
>>>> ~ $
>>>
>>>Maybe because it's not an error.
>>
>> And maybe the sun rises in the east.
>>
>> And yet you can see where he is coming from. In some sense, the term
>> "standard error" is a misnomer. It really is/should be "Out of Band".
>>
>> Really, the standard error channel should be used for any OOB type
>> information - that is, other than the actual, genuine output of the command.
>
>In which way isn't the "Binary file (..." message "actual,
>genuine output of grep"?
The answer to that is obvious. You may not agree with it, but feigning
ignorance is not going to win you any points.
>It seems to me that it carries information requested by the user (can
>"hi" be found in the standard input?).
I see where you're going with this - but the point is that if you are
looking for a yes/no answer, you should be using the return status of
grep as your indicator, not trying to parse the output.
|