[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57604: [ef]grep usage -> POSIXLY_CORRECT?

From: Paul Eggert
Subject: bug#57604: [ef]grep usage -> POSIXLY_CORRECT?
Date: Mon, 5 Sep 2022 20:28:49 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

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:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]