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