public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Xi Ruoyao <xry111@xry111.site>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>,
	Rainer Orth <ro@cebitec.uni-bielefeld.de>,
	 Arnaud Charlet <charlet@adacore.com>,
	Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Subject: Re: [PATCH v2 6/7] contrib: use grep -E instead of egrep
Date: Mon, 27 Jun 2022 10:02:57 +0100	[thread overview]
Message-ID: <CACb0b4kz+NaLqiCHbQh3f8KmDu=oJxdo2PzPcwH-xjT16WGsTg@mail.gmail.com> (raw)
In-Reply-To: <e173263bcb24fc77354f1dd6629fd155e7b55788.camel@xry111.site>

On Mon, 27 Jun 2022 at 07:12, Xi Ruoyao <xry111@xry111.site> wrote:
>
> 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 (){
>
>      local found=false
>      cat $inp \
> -       | egrep $color -- "$arg" \
> +       | grep -E $color -- "$arg" \
>         > "$tmp" && found=true
>
>      if $found; then
> @@ -130,8 +130,8 @@ ag (){
>
>      local found=false
>      cat $inp \
> -       | egrep $color -- "$arg1" \
> -       | egrep $color -- "$arg2" \
> +       | grep -E $color -- "$arg1" \
> +       | grep -E $color -- "$arg2" \
>         > "$tmp" && found=true
>
>      if $found; then
> @@ -148,8 +148,8 @@ vg (){
>
>      local found=false
>      cat $inp \
> -       | egrep -v -- "$varg" \
> -       | egrep $color -- "$arg" \
> +       | grep -E -v -- "$varg" \
> +       | grep -E $color -- "$arg" \
>         > "$tmp" && found=true
>
>      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
>
> +# Prefer "grep -E" which should work with POSIX-conform grep, but fallback

"POSIX-conforming"

> +# to "egrep" (which is deprecated for a long time) if grep does not support

I'd just say "to deprecate egrep" or "to egrep (which is deprecated)".
There's no need to say anything about how long it's been deprecated.


> +# -E.
> +if test -z "$EGREP" ; then
> +  if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then
> +    EGREP="grep -E"
> +  else
> +    EGREP="egrep"
> +  fi
> +fi
> +
>  : ${filesuffix=}; export filesuffix
>  : ${move=true}; export move
>  : ${forcemail=false}; export forcemail
> @@ -77,7 +88,7 @@ for file in $files; do
>      { $anychange ||
>        anychange=`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" = 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
>
> +# 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 support

Ditto.

> +# -E.
> +if test -z "$EGREP" ; then
> +  if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then
> +    EGREP="grep -E"
> +  else
> +    EGREP="egrep"
> +  fi
> +fi
> +
>  # Parse command line arguments.
>  while test -n "$1" ; do
>   case "$1" in
> --
> 2.36.1
>
>


  reply	other threads:[~2022-06-27  9:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
2022-07-05  0:58   ` Hans-Peter Nilsson
2022-07-08  3:46   ` Eric Gallager
2022-06-27  6:09 ` [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep Xi Ruoyao
2022-06-27  9:54   ` Eric Gallager
2022-06-27  6:09 ` [PATCH v2 3/7] libbacktrace: use grep instead of fgrep Xi Ruoyao
2022-06-27  9:07   ` Jonathan Wakely
2022-06-27 20:00   ` Ian Lance Taylor
2022-06-27  6:10 ` [PATCH v2 4/7] fortran: " Xi Ruoyao
2023-05-10 19:29   ` Bernhard Reutner-Fischer
2023-05-10 20:02     ` Thomas Koenig
2023-05-11  9:01       ` Pushed: " Xi Ruoyao
2022-06-27  6:11 ` [PATCH v2 5/7] testsuite: stop using obsoleted egrep Xi Ruoyao
2022-06-27  6:50   ` Arnaud Charlet
2022-06-27  6:12 ` [PATCH v2 6/7] contrib: use grep -E instead of egrep Xi Ruoyao
2022-06-27  9:02   ` Jonathan Wakely [this message]
2022-06-27  6:14 ` [PATCH 7/7] libffi: Use $EGREP " Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACb0b4kz+NaLqiCHbQh3f8KmDu=oJxdo2PzPcwH-xjT16WGsTg@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rep.dot.nop@gmail.com \
    --cc=ro@cebitec.uni-bielefeld.de \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).