Date: Thu, 8 Aug 2013 11:53:47 +0000 (UTC) From: "Andrey A. Chernov" <ache@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254093 - head/gnu/usr.bin/grep Message-ID: <201308081153.r78BrlFM041114@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ache Date: Thu Aug 8 11:53:47 2013 New Revision: 254093 URL: http://svnweb.freebsd.org/changeset/base/254093 Log: 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. Modified: head/gnu/usr.bin/grep/grep.c Modified: head/gnu/usr.bin/grep/grep.c ============================================================================== --- head/gnu/usr.bin/grep/grep.c Thu Aug 8 11:24:25 2013 (r254092) +++ head/gnu/usr.bin/grep/grep.c Thu Aug 8 11:53:47 2013 (r254093) @@ -301,14 +301,16 @@ reset (int fd, char const *file, struct 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308081153.r78BrlFM041114>