diff options
author | ache <ache@FreeBSD.org> | 2013-08-08 11:53:47 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2013-08-08 11:53:47 +0000 |
commit | 8bff628d3a60d6a6f3d9a43e1eb4447d8a4ee084 (patch) | |
tree | ee318e47afedc507e7897ff2a84a6d0727e327c9 /gnu | |
parent | 612b57c66cc5aaca953d81189ee30c495f59dccd (diff) | |
download | FreeBSD-src-8bff628d3a60d6a6f3d9a43e1eb4447d8a4ee084.zip FreeBSD-src-8bff628d3a60d6a6f3d9a43e1eb4447d8a4ee084.tar.gz |
Part of r245761 makes "grep -D skip" broken for pipes, i.e.
echo xxx | grep -D skip xxx
returns nothing. Instead of just removing added S_ISFIFO condition
(originally absent in this version of grep), make it work as latest
GNU version does: don't skip directories and devices if fd == STDIN_FILENO.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/grep/grep.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gnu/usr.bin/grep/grep.c b/gnu/usr.bin/grep/grep.c index 223ee91..61d1bf1 100644 --- a/gnu/usr.bin/grep/grep.c +++ b/gnu/usr.bin/grep/grep.c @@ -301,14 +301,16 @@ reset (int fd, char const *file, struct stats *stats) error (0, errno, "fstat"); return 0; } - if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) - return 0; + if (fd != STDIN_FILENO) { + if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) + return 0; #ifndef DJGPP - if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode))) + if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode))) #else - if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode))) + if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode))) #endif - return 0; + return 0; + } if ( BZflag || #if HAVE_LIBZ > 0 |