Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Deprecation of egrep



> 2022/09/11 2:26, Ellenor Bjornsdottir <ellenor@xxxxxxxxxxxxx> wrote:
> 
> grep from which system? GNU?

GNU grep-3.8. At least Debian-sid and the latest Arch Linux already use it.

> 2022/09/11 1:04, Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx> wrote:
> 
> Changing all occurrences of "egrep" to "grep -E" in our test scripts will fix this.

It works on Linux, {Free,Open,Net,Dragonfly}BSD, macOS and Cygwin.
But I'm not sure if it works on Solaris (and other commercial UNIXes) or not.
Online Solaris manpage indicates that /usr/bin/grep does not accept -E
(although /usr/xpg4/bin/grep accepts it).

Could someone test on Solaris etc.?

> 2022/09/11 9:10, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 
> A quick check reveals six uses, all of which could be replaced with
> zsh pattern matching 

If we can not simply replace egrep by 'grep -E', this would be the simplest
fix; see the patch below.

configure sets EGREP to either 'grep -E' or 'egrep', so propagating this
to ztst.zsh (in some way) would be another (more complex) possibility.


diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index aca275c1c..248180b34 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -94,6 +94,14 @@ tail() {
   command tail "$argv[@]"
 }
 
+# Define our egrep (works only as a pipe). GNU grep-3.8 forces us to use
+# 'grep -E' instead of egrep, but on some systems grep may not accept -E.
+egrep () {
+  while read line; do
+    [[ $line = *(${~1})* ]] && print $line
+  done
+}
+
 # The source directory is not necessarily the current directory,
 # but if $0 doesn't contain a `/' assume it is.
 if [[ $0 = */* ]]; then







Messages sorted by: Reverse Date, Date, Thread, Author