GNU bug report logs - #57604
[ef]grep usage -> POSIXLY_CORRECT?

Previous Next

Package: grep;

Reported by: Karl Berry <karl <at> freefriends.org>

Date: Mon, 5 Sep 2022 22:08:02 UTC

Severity: normal

Merged with 58502, 60257, 66582

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Karl Berry <karl <at> freefriends.org>
Cc: 57604 <at> debbugs.gnu.org
Subject: bug#57604: [ef]grep usage -> POSIXLY_CORRECT?
Date: Mon, 5 Sep 2022 20:28:49 -0500
On 9/5/22 17:07, Karl Berry wrote:
> I have hundreds of scripts that use [ef]grep since for many
> years they were either the only, or then later the most portable, way to
> get the behavior.

Actually, egrep and fgrep were not entirely portable even before POSIX 
deprecated them in 2001. For example, in 1998 they were absent from SCO 
Unix unless you installed optional packages; see 
<https://www.scosales.com/ta/kb/105933.html>.

Similar problems are more common today now that POSIX no longer requires 
egrep and fgrep, for example, see OpenWRT bug 17803 
<https://github.com/openwrt/packages/issues/17803>. These days, my 
impression is that it's more portable to use grep -E than to use egrep. 
Of course neither is perfectly portable, but if a script is going to use 
just one or just the other, grep -E is the way to go nowadays.

>   I suggest giving that warning only if POSIXLY_CORRECT is set.
That wouldn't be right, as POSIXLY_CORRECT governs misfeatures required 
by POSIX, which isn't the case here: egrep and fgrep are extensions to 
POSIX.

For the bug report that prompted those warnings, please see:

https://bugs.gnu.org/49996





This bug report was last modified 1 year and 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.