From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 98FBF386DC71 for ; Mon, 27 Jun 2022 06:12:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 98FBF386DC71 Received: from [192.168.124.21] (unknown [113.140.11.126]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 470E066807; Mon, 27 Jun 2022 02:12:09 -0400 (EDT) Message-ID: Subject: [PATCH v2 6/7] contrib: use grep -E instead of egrep From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Arnaud Charlet , Bernhard Reutner-Fischer , Jonathan Wakely Date: Mon, 27 Jun 2022 14:12:05 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 MIME-Version: 1.0 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, GIT_PATCH_0, LIKELY_SPAM_FROM, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_PASS, SPF_PASS, TXREP, T_PDS_OTHER_BAD_TLD, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2022 06:12:12 -0000 egrep has been deprecated in favor of grep -E for a long time, and the next grep release (3.8 or 4.0) will print a warning of egrep is used. Stop using egrep so we won't see the warning. Some non-POSIX grep implementations does not support -E option, so for test_summary and warn_summary we prefer grep -E, but fallback to egrep if grep -E does not work. For check_GNU_style.sh, I think it is only used by developers so hard coding grep -E is OK. contrib/ChangeLog: * check_GNU_style.sh: Use grep -E instead of egrep. * test_summary: Use grep -E instead of egrep if it works. * warn_summary: Likewise. --- contrib/check_GNU_style.sh | 10 +++++----- contrib/test_summary | 13 ++++++++++++- contrib/warn_summary | 13 ++++++++++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh index fb7494661ee..535be65f063 100755 --- a/contrib/check_GNU_style.sh +++ b/contrib/check_GNU_style.sh @@ -113,7 +113,7 @@ g (){ =20 local found=3Dfalse cat $inp \ - | egrep $color -- "$arg" \ + | grep -E $color -- "$arg" \ > "$tmp" && found=3Dtrue =20 if $found; then @@ -130,8 +130,8 @@ ag (){ =20 local found=3Dfalse cat $inp \ - | egrep $color -- "$arg1" \ - | egrep $color -- "$arg2" \ + | grep -E $color -- "$arg1" \ + | grep -E $color -- "$arg2" \ > "$tmp" && found=3Dtrue =20 if $found; then @@ -148,8 +148,8 @@ vg (){ =20 local found=3Dfalse cat $inp \ - | egrep -v -- "$varg" \ - | egrep $color -- "$arg" \ + | grep -E -v -- "$varg" \ + | grep -E $color -- "$arg" \ > "$tmp" && found=3Dtrue =20 if $found; then diff --git a/contrib/test_summary b/contrib/test_summary index 5760b053ec2..f17bf54f8ec 100755 --- a/contrib/test_summary +++ b/contrib/test_summary @@ -54,6 +54,17 @@ if test -z "$AWK" ; then done fi =20 +# Prefer "grep -E" which should work with POSIX-conform grep, but fallback +# to "egrep" (which is deprecated for a long time) if grep does not suppor= t +# -E. +if test -z "$EGREP" ; then + if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then + EGREP=3D"grep -E" + else + EGREP=3D"egrep" + fi +fi + : ${filesuffix=3D}; export filesuffix : ${move=3Dtrue}; export move : ${forcemail=3Dfalse}; export forcemail @@ -77,7 +88,7 @@ for file in $files; do { $anychange || anychange=3D`diff $file.sent $file 2>/dev/null | if test ! -f $file.sent || - egrep '^[<>] (XPASS|FAIL)' >/dev/null; then + $EGREP '^[<>] (XPASS|FAIL)' >/dev/null; then echo true else echo false diff --git a/contrib/warn_summary b/contrib/warn_summary index d4c8b6cdb19..afa11802ee1 100755 --- a/contrib/warn_summary +++ b/contrib/warn_summary @@ -57,7 +57,7 @@ subdirectoryFilter() else if test "$filter" =3D nosub ; then # Omit all subdirectories. - egrep -v '/gcc/(ch|cp|f|fortran|ada|intl|fixinc)/' + $EGREP -v '/gcc/(ch|cp|f|fortran|ada|intl|fixinc)/' else # Pass through only subdir $filter. grep "/gcc/$filter/" @@ -155,6 +155,17 @@ if test -z "$AWK" ; then done fi =20 +# Prefer "grep -E" which should work with POSIX-conform grep, but fallback +# to "egrep" (which is deprecated for a long time) if grep does not suppor= t +# -E. +if test -z "$EGREP" ; then + if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then + EGREP=3D"grep -E" + else + EGREP=3D"egrep" + fi +fi + # Parse command line arguments. while test -n "$1" ; do case "$1" in --=20 2.36.1