diff options
author | Jim Meyering <meyering@fb.com> | 2016-09-23 20:46:19 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2016-09-23 22:08:43 -0700 |
commit | eaa1541d8e714621abe5a8235f4a59cbf64b2d1f (patch) | |
tree | e44044e15e141c5d58769ba2765e1a0a571d91d6 | |
parent | 72aa3b232e847e8ab78093e87dc1ee6471d192ac (diff) | |
download | grep-eaa1541d8e714621abe5a8235f4a59cbf64b2d1f.tar.gz |
grep: avoid unwarranted "input file 'F' is also the output" on *BSD
On *BSD systems, any command like "echo y | grep x", where grep reads
from a pipe and writes to standard output, would mistakenly emit this:
grep: input file '(standard input)' is also the output
* src/grep.c (grepdesc): Ensure that the file descriptor we're
reading is a regular one before using SAME_INODE to test whether
it is the same as the descriptor open on standard output.
Nelson Beebe reported privately that the foad1 tests failed on many
BSD systems. Exposed by commit v2.25-2-gaf6af28.
https://bugs.gnu.org/24522
-rw-r--r-- | src/grep.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1819,7 +1819,7 @@ grepdesc (int desc, bool command_line) input==output, while there is no risk of infloop, there is a race condition that could result in "alternate" output. */ if (!out_quiet && list_files == LISTFILES_NONE && 1 < max_count - && SAME_INODE (st, out_stat)) + && S_ISREG (st.st_mode) && SAME_INODE (st, out_stat)) { if (! suppress_errors) error (0, 0, _("input file %s is also the output"), quote (filename)); |