Hi Jan, Jan Stary wrote on Wed, Mar 15, 2017 at 08:17:39PM +0100:
> Apparently, grep can be called with both -E and -F: > > $ printf "foo\nbar\n" | grep -EF '(foo|bar)' > $ printf "foo\nbar\n" | grep -FE '(foo|bar)' > foo > bar > > and the same happens with egrep and fgrep. Indeed, > > case 'E': > Fflag = 0; > Eflag = 1; > break; > case 'F': > Eflag = 0; > Fflag = 1; > break; What you describe is a POSIX violation: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02 http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html > Should grep (or egrep or fgrep) protest > if both -E and -F (or -F or -E, respectively) > are specified? Yes, that is what POSIX requires. It must error out. And indeed, the following do error out on -EF and -FE: * GNU grep * DragonFly BSD (uses GNU grep) * illumos (in both versions: in libcmd and in grep_xpg4) * Solaris 11 /usr/xpg4/bin/grep * Solaris 9 /usr/xpg4/bin/grep However, the following silently allow the last one to win: * OpenBSD * FreeBSD * NetBSD The NetBSD implementation was copied from FreeBSD in 2011. The FreeBSD implementation was copied from OpenBSD in 2010. The OpenBSD implementation was written from scratch by Carson Harding in 2000 or 2001. So it looks like this is our Very Own Bug, and it has used some opportunities to multiply. > (IMHO not, but anyway?) This should probably be fixed, but so shortly before release is not a good time - the fallout might be entertaining... Yours, Ingo

