GNU bug report logs - #25651
Weird output of random files

Previous Next

Package: grep;

Reported by: "rexkogitans <at> gmx.at" <rexkogitans <at> gmx.at>

Date: Tue, 7 Feb 2017 20:32:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 25651-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "rexkogitans <at> gmx.at" <rexkogitans <at> gmx.at>, 25651-done <at> debbugs.gnu.org
Subject: Re: bug#25651: Weird output of random files
Date: Tue, 7 Feb 2017 14:30:56 -0800
On 02/07/2017 12:24 PM, rexkogitans <at> gmx.at wrote:
> Maybe, the command line is interpreted as:
>
>    * r ... search files recursively in directories. Note, that input is
>    read from stdin here.
>
>    * e ... use the following pattern
>
>    * h ... this is the pattern expected by "e"

Yes, that's the interpretation that 'grep' uses, except that it reads 
input from ".", not from stdin. That is, 'grep -r PAT' is equivalen to 
'grep -r PAT .'. This is for convenience: as it does not make sense to 
use -r on an input stream, the default input is '.' instead of '-' when 
-r is used.

grep cannot "know" that the user wanted it to read from stdin, for the 
same reason that it does not "know" that the user wanted it to read from 
stdin here:

   ps ax | grep 0:00 xyz

This causes 'grep' to read from the file 'xyz', instead of the desired 
behavior of looking for the pattern '0:00 xyz' in the 'ps ax' output. 
The 'ps ax' output is ignored.





This bug report was last modified 8 years and 159 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.