public inbox for [email protected]  
help / color / mirror / Atom feed
egrep is obsolescent
3+ messages / 2 participants
[nested] [flat]

* egrep is obsolescent
@ 2026-05-13 15:24  Tom Lane <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2026-05-13 15:24 UTC (permalink / raw)
  To: [email protected]

While running pgperltidy just now on my recently-updated
Linux workstation, I got

$ src/tools/pgindent/pgperltidy .
egrep: warning: egrep is obsolescent; using grep -E

OK, that's a bit in-your-face, but it's not inaccurate.
AFAICT, "egrep" has never been in POSIX, while "grep -E"
has been there at least since POSIX 2008.

So I propose the attached patch, which is just s/egrep/grep -E/g.

I did not touch the two usages in port/aix/mkldexport.sh, though.
I'm not sure what the standardization situation is in AIX, and
this warning doesn't seem like something they'd do anyway.

There is also a reference in configure, which is not a problem
because it tries "grep -E" first.

			regards, tom lane



Attachments:

  [text/x-diff] use-grep-E-not-egrep.patch (2.7K, 2-use-grep-E-not-egrep.patch)
  download | inline diff:
diff --git a/doc/src/sgml/func/func-matching.sgml b/doc/src/sgml/func/func-matching.sgml
index af60e9898de..ae1dff66722 100644
--- a/doc/src/sgml/func/func-matching.sgml
+++ b/doc/src/sgml/func/func-matching.sgml
@@ -505,7 +505,7 @@ substring('foobar' SIMILAR '#"o_b#"%' ESCAPE '#')    <lineannotation>NULL</linea
      <acronym>POSIX</acronym> regular expressions provide a more
      powerful means for pattern matching than the <function>LIKE</function> and
      <function>SIMILAR TO</function> operators.
-     Many Unix tools such as <command>egrep</command>,
+     Many Unix tools such as <command>grep -E</command>,
      <command>sed</command>, or <command>awk</command> use a pattern
      matching language that is similar to the one described here.
     </para>
@@ -1065,7 +1065,7 @@ regexp_substr('ABCDEFGHI', '(c..)(...)', 1, 1, 'i', 2)
     Regular expressions (<acronym>RE</acronym>s), as defined in
     <acronym>POSIX</acronym> 1003.2, come in two forms:
     <firstterm>extended</firstterm> <acronym>RE</acronym>s or <acronym>ERE</acronym>s
-    (roughly those of <command>egrep</command>), and
+    (roughly those of <command>grep -E</command>), and
     <firstterm>basic</firstterm> <acronym>RE</acronym>s or <acronym>BRE</acronym>s
     (roughly those of <command>ed</command>).
     <productname>PostgreSQL</productname> supports both forms, and
diff --git a/src/tools/find_typedef b/src/tools/find_typedef
index 24e9b76651d..fec0520c32e 100755
--- a/src/tools/find_typedef
+++ b/src/tools/find_typedef
@@ -36,12 +36,12 @@ do	# if objdump -W is recognized, only one line of error should appear
 	if [ `objdump -W 2>&1 | wc -l` -eq 1 ]
 	then	# Linux
 		objdump -W "$DIR"/* |
-		egrep -A3 '\(DW_TAG_typedef\)' |
+		grep -E -A3 '\(DW_TAG_typedef\)' |
 		awk ' $2 == "DW_AT_name" {print $NF}'
 	elif [ `readelf -w 2>&1 | wc -l` -gt 1 ]
 	then	# FreeBSD, similar output to Linux
 		readelf -w "$DIR"/* |
-		egrep -A3 '\(DW_TAG_typedef\)' |
+		grep -E -A3 '\(DW_TAG_typedef\)' |
 		awk ' $1 == "DW_AT_name" {print $NF}'
 	fi
 done |
@@ -50,4 +50,4 @@ sort |
 uniq |
 # these are used both for typedefs and variable names
 # so do not include them
-egrep -v '^(date|interval|timestamp|ANY)$'
+grep -E -v '^(date|interval|timestamp|ANY)$'
diff --git a/src/tools/perlcheck/find_perl_files b/src/tools/perlcheck/find_perl_files
index 20dceb800d0..406ec7f3a08 100644
--- a/src/tools/perlcheck/find_perl_files
+++ b/src/tools/perlcheck/find_perl_files
@@ -12,7 +12,7 @@ find_perl_files () {
 		find "$@" -type f -name '*.p[lm]' -print
 		# take executable files that file(1) thinks are perl files
 		find "$@" -type f -perm -100 -exec file {} \; -print |
-		egrep -i ':.*perl[0-9]*\>' |
+		grep -E -i ':.*perl[0-9]*\>' |
 		cut -d: -f1
 	} | sort -u | grep -v '^\./\.git/'
 }


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: egrep is obsolescent
@ 2026-05-13 15:32  Peter Eisentraut <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Peter Eisentraut @ 2026-05-13 15:32 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; [email protected]

On 13.05.26 17:24, Tom Lane wrote:
> While running pgperltidy just now on my recently-updated
> Linux workstation, I got
> 
> $ src/tools/pgindent/pgperltidy .
> egrep: warning: egrep is obsolescent; using grep -E
> 
> OK, that's a bit in-your-face, but it's not inaccurate.
> AFAICT, "egrep" has never been in POSIX, while "grep -E"
> has been there at least since POSIX 2008.
> 
> So I propose the attached patch, which is just s/egrep/grep -E/g.

Looks good to me.

> I did not touch the two usages in port/aix/mkldexport.sh, though.
> I'm not sure what the standardization situation is in AIX, and
> this warning doesn't seem like something they'd do anyway.

It appears that those invocations don't actually need the "e" part of 
egrep, so they could just be grep?

> There is also a reference in configure, which is not a problem
> because it tries "grep -E" first.

Yeah, Autoconf addressed this some decades ago, so it should be fine.






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: egrep is obsolescent
@ 2026-05-13 15:55  Tom Lane <[email protected]>
  parent: Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2026-05-13 15:55 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; +Cc: [email protected]

Peter Eisentraut <[email protected]> writes:
> On 13.05.26 17:24, Tom Lane wrote:
>> I did not touch the two usages in port/aix/mkldexport.sh, though.
>> I'm not sure what the standardization situation is in AIX, and
>> this warning doesn't seem like something they'd do anyway.

> It appears that those invocations don't actually need the "e" part of 
> egrep, so they could just be grep?

Oh, good point.  I'll make it so, just for cleanliness.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-05-13 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-13 15:24 egrep is obsolescent Tom Lane <[email protected]>
2026-05-13 15:32 ` Peter Eisentraut <[email protected]>
2026-05-13 15:55   ` Tom Lane <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox