config: add $egrep

Introduce a new variable set in $PLAN9/config:
$egrep, which is conditionally set to either
`egrep` or `grep -E`, based on platform, and use
this when we want to invoke `egrep`.

This works around the endless warnings from GNU
grep stating that `egrep` is deprecated in favor
of `grep -E`, when run on e.g. Linux.
This commit is contained in:
Dan Cross
2025-07-22 14:42:03 +00:00
parent 28690cd427
commit 564d45b5a5
9 changed files with 27 additions and 11 deletions

View File

@@ -65,11 +65,18 @@ DragonFly|*BSD)
echo "CFLAGS='-pthread'" >> $PLAN9/config
awk=awk
;;
*Linux*)
awk=awk
egrep='grep -E'
;;
*)
egrep=egrep
awk=awk
;;
esac
echo "egrep='$egrep'" >>$PLAN9/config
(
if [ `uname` = SunOS ]; then
# On Solaris x86, uname -p cannot be trusted.

5
bin/9c
View File

@@ -8,6 +8,7 @@ usegcc()
-O2 \
-c \
-Wall \
-Wno-array-parameter \
-Wno-parentheses \
-Wno-missing-braces \
-Wno-switch \
@@ -23,7 +24,7 @@ usegcc()
-fno-omit-frame-pointer \
-fsigned-char \
-fcommon \
-std=c11 \
-std=gnu11 \
"
# want to put -fno-optimize-sibling-calls here but
# that option only works with gcc3+ it seems
@@ -56,7 +57,7 @@ quiet()
ignore=$ignore'|expanded from macro'
grep -v '__p9l_autolib_' "$1" |
egrep -v "$ignore" |
$egrep -v "$ignore" |
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
$(which uniq) 1>&2 # avoid built-in uniq on SunOS
}

4
bin/9l
View File

@@ -146,7 +146,7 @@ then
grep '__p9l_autolib_[a-zA-Z0-9+-]*' |
sed 's/.*__p9l_autolib_//; s/:.*//' |
sort -u |
egrep -v '^(thread|draw)$'
$egrep -v '^(thread|draw)$'
`
a="$a $b"
done
@@ -337,7 +337,7 @@ quiet()
ignore=$ignore'|ld: warning: ignoring duplicate libraries:'
sed 's/.*: In function `[^:]*: *//' "$1" |
egrep -v "$ignore"
$egrep -v "$ignore"
}
# Must use temp file to avoid pipe; pipe loses status.

2
dist/checkman.awk vendored
View File

@@ -446,7 +446,7 @@ END {
gsub("\\(", " \\(", b)
gsub("\\)", "\\)", b)
split(tolower(i), a, "/")
print "egrep -in '^\\.IR.*" b "' $PLAN9/man/man*/* # Need " tolower(i) |"sort"
print "grep -in '^\\.IR.*" b "' $PLAN9/man/man*/* # Need " tolower(i) |"sort"
}
}
close("sort")

View File

@@ -12,6 +12,6 @@ HFILES=\
<$PLAN9/src/mkone
KVM=`{if uname |egrep 'BSD' | egrep -v 'OpenBSD' >/dev/null; then echo -lkvm; fi}
KVM=`{if uname | grep 'BSD' | grep -v 'OpenBSD' >/dev/null; then echo -lkvm; fi}
LDFLAGS=$LDFLAGS $KVM

View File

@@ -24,7 +24,7 @@ fi
if [ "x$WSYSTYPE" = "x" ]; then
if [ "x`uname`" = "xDarwin" ]; then
if sw_vers | egrep 'ProductVersion: (10\.[0-9]\.|10\.1[012])$' >/dev/null; then
if sw_vers | $egrep 'ProductVersion: (10\.[0-9]\.|10\.1[012])$' >/dev/null; then
echo 1>&2 'OS X 10.12 and older are not supported'
exit 1
fi

View File

@@ -1,11 +1,11 @@
<$PLAN9/src/mkhdr
TARG=`ls *.[cy] *.lx | egrep -v "\.tab\.c$|^x\." | sed 's/\.[cy]//; s/\.lx//'`
TARG=`ls *.[cy] *.lx | $egrep -v "\.tab\.c$|^x\." | sed 's/\.[cy]//; s/\.lx//'`
<$PLAN9/src/mkmany
BUGGERED='CVS|faces|factotum|lp|ip|mailfs|upas|vncv|mnihongo|mpm|index|u9fs|secstore|smugfs|snarfer'
DIRS=lex `ls -l |sed -n 's/^d.* //p' |egrep -v "^($BUGGERED)$"|egrep -v '^lex$'` $FONTSRV
DIRS=lex `ls -l |sed -n 's/^d.* //p' |$egrep -v "^($BUGGERED)$"|grep -v '^lex$'` $FONTSRV
<$PLAN9/src/mkdirs

View File

@@ -1,5 +1,13 @@
#!/bin/bash
egrep=egrep
tag="${SYSNAME:-`uname`}"
case "$tag" in
*Linux*)
egrep='grep -E'
;;
esac
aflag=false
if [ "$1" = -a ]; then
aflag=true
@@ -10,7 +18,7 @@ files="$@"
if [ $# = 0 ]; then
files=$(echo ./test.rc;
grep -l '^#!/usr/local/plan9/bin/rc' /usr/local/plan9/bin/{*,*/*} 2>/dev/null;
grep -R -l '^#!/bin/rc' $HOME/pub/plan9 | egrep -v 'plan9/(lib/(oui|pci)|sys/man|sys/lib/man|sys/lib/scsicodes)' 2>/dev/null)
grep -R -l '^#!/bin/rc' $HOME/pub/plan9 | $egrep -v 'plan9/(lib/(oui|pci)|sys/man|sys/lib/man|sys/lib/scsicodes)' 2>/dev/null)
fi
for i in $files

View File

@@ -1,7 +1,7 @@
<mkhdr
BUGGERED='fs|fmt|utf'
LIBDIRS=`ls -ld lib* | sed -n 's/^d.* //p' |egrep -v "^lib($BUGGERED)$"`
LIBDIRS=`ls -ld lib* | sed -n 's/^d.* //p' |$egrep -v "^lib($BUGGERED)$"`
DIRS=\
$LIBDIRS\