GNU bug report logs -
#25651
Weird output of random files
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#25651: Weird output of random files
which was filed against the grep package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 25651 <at> debbugs.gnu.org.
--
25651: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25651
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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.
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
Hello,
I could repeatedly reproduce an unexpected behaviour on several Linux
systems (two installations of Arch Linux [newest state], a Debian [8.7]
and a Ubuntu [16.4]).
I ran the following command - when I first ran it, it was accidentially
ps ax | grep -reh
I wanted to grep for processes containing the string "-reh", but forgot
the "-e" which was necessary due to the leading dash in the string.
On all systems, grep outputs hundreds of (not even matching) lines from
files of my home directory, not at all related to the output of ps,
which I piped into grep.
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"
It may be that all the lines ouput by grep contain "h".
Although expected to be identical, this command works as expected:
ps ax | grep -reh /dev/stdin
Kind regards,
rexkogitans
[Message part 5 (text/html, inline)]
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.