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 echo "CFLAGS='-pthread'" >> $PLAN9/config
awk=awk awk=awk
;; ;;
*Linux*)
awk=awk
egrep='grep -E'
;;
*) *)
egrep=egrep
awk=awk awk=awk
;; ;;
esac esac
echo "egrep='$egrep'" >>$PLAN9/config
( (
if [ `uname` = SunOS ]; then if [ `uname` = SunOS ]; then
# On Solaris x86, uname -p cannot be trusted. # On Solaris x86, uname -p cannot be trusted.

5
bin/9c
View File

@@ -8,6 +8,7 @@ usegcc()
-O2 \ -O2 \
-c \ -c \
-Wall \ -Wall \
-Wno-array-parameter \
-Wno-parentheses \ -Wno-parentheses \
-Wno-missing-braces \ -Wno-missing-braces \
-Wno-switch \ -Wno-switch \
@@ -23,7 +24,7 @@ usegcc()
-fno-omit-frame-pointer \ -fno-omit-frame-pointer \
-fsigned-char \ -fsigned-char \
-fcommon \ -fcommon \
-std=c11 \ -std=gnu11 \
" "
# want to put -fno-optimize-sibling-calls here but # want to put -fno-optimize-sibling-calls here but
# that option only works with gcc3+ it seems # that option only works with gcc3+ it seems
@@ -56,7 +57,7 @@ quiet()
ignore=$ignore'|expanded from macro' ignore=$ignore'|expanded from macro'
grep -v '__p9l_autolib_' "$1" | 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' | 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 $(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+-]*' | grep '__p9l_autolib_[a-zA-Z0-9+-]*' |
sed 's/.*__p9l_autolib_//; s/:.*//' | sed 's/.*__p9l_autolib_//; s/:.*//' |
sort -u | sort -u |
egrep -v '^(thread|draw)$' $egrep -v '^(thread|draw)$'
` `
a="$a $b" a="$a $b"
done done
@@ -337,7 +337,7 @@ quiet()
ignore=$ignore'|ld: warning: ignoring duplicate libraries:' ignore=$ignore'|ld: warning: ignoring duplicate libraries:'
sed 's/.*: In function `[^:]*: *//' "$1" | sed 's/.*: In function `[^:]*: *//' "$1" |
egrep -v "$ignore" $egrep -v "$ignore"
} }
# Must use temp file to avoid pipe; pipe loses status. # 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)
gsub("\\)", "\\)", b) gsub("\\)", "\\)", b)
split(tolower(i), a, "/") 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") close("sort")

View File

@@ -12,6 +12,6 @@ HFILES=\
<$PLAN9/src/mkone <$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 LDFLAGS=$LDFLAGS $KVM

View File

@@ -24,7 +24,7 @@ fi
if [ "x$WSYSTYPE" = "x" ]; then if [ "x$WSYSTYPE" = "x" ]; then
if [ "x`uname`" = "xDarwin" ]; 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' echo 1>&2 'OS X 10.12 and older are not supported'
exit 1 exit 1
fi fi

View File

@@ -1,11 +1,11 @@
<$PLAN9/src/mkhdr <$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 <$PLAN9/src/mkmany
BUGGERED='CVS|faces|factotum|lp|ip|mailfs|upas|vncv|mnihongo|mpm|index|u9fs|secstore|smugfs|snarfer' 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 <$PLAN9/src/mkdirs

View File

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

View File

@@ -1,7 +1,7 @@
<mkhdr <mkhdr
BUGGERED='fs|fmt|utf' 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=\ DIRS=\
$LIBDIRS\ $LIBDIRS\