From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Re: egrep in binutils
Date: Wed, 28 Sep 2022 23:01:34 +0930 [thread overview]
Message-ID: <YzRMtuMy/waekpOU@squeak.grove.modra.org> (raw)
In-Reply-To: <YzPO42EUjIKbwPxQ@squeak.grove.modra.org>
On Wed, Sep 28, 2022 at 02:04:43PM +0930, Alan Modra wrote:
> --- a/ld/testsuite/ld-elfvers/vers.exp
> +++ b/ld/testsuite/ld-elfvers/vers.exp
> @@ -109,7 +109,9 @@ proc test_ar { test lib object expect } {
> return
> }
>
> - set cmd "$nm --print-armap $tmpdir/$lib | grep \\\ in\\\ | egrep VERS\\\|bar\\\|foo | grep -v ^\\\\. | sort > $tmpdir/nm.out"
> + set cmd "$nm --print-armap $tmpdir/$lib | grep \" in \" | grep \"VERS
> +bar
> +foo\" | grep -v ^\\\\. | sort > $tmpdir/nm.out"
> verbose -log $cmd
> catch "exec $cmd" exec_output
> if [string match "" $exec_output] then {
I've just been looking at autoconf documentation for pitfalls with grep,
and the above multi-line pattern is said to "fail with traditional
grep implementations and with OpenBSD 3.8 grep".
binutils/
* embedspu.sh: Replace multi-line grep with sed.
ld/
* testsuite/ld-elfvers/vers.exp: Replace multi-line grep with sed.
diff --git a/binutils/embedspu.sh b/binutils/embedspu.sh
index 361206f7d88..d72773946c2 100644
--- a/binutils/embedspu.sh
+++ b/binutils/embedspu.sh
@@ -108,11 +108,7 @@ main ()
READELF="$prog"
# Sanity check the input file
- match="Class:.*ELF32
-Type:.*EXEC
-Machine:.*SPU
-Machine:.*17"
- if test `${READELF} -h ${INFILE} | grep "${match}" | wc -l` != 3
+ if test `${READELF} -h ${INFILE} | sed -n -e '/Class:.*ELF32/p' -e '/Type:.*EXEC/p' -e '/Machine:.*SPU/p' -e '/Machine:.*17/p' | sed -n '$='` != 3
then
echo "${INFILE}: Does not appear to be an SPU executable"
exit 1
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
index 9af6bb9fd92..3e2ba2aac07 100644
--- a/ld/testsuite/ld-elfvers/vers.exp
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -109,9 +109,7 @@ proc test_ar { test lib object expect } {
return
}
- set cmd "$nm --print-armap $tmpdir/$lib | grep \" in \" | grep \"VERS
-bar
-foo\" | grep -v ^\\\\. | sort > $tmpdir/nm.out"
+ set cmd "$nm --print-armap $tmpdir/$lib | sed -n -e /^\\\\./d -e \"/^VERS.* in /p\" -e \"/bar.* in /p\" -e \"/foo.* in /p\" | sort > $tmpdir/nm.out"
verbose -log $cmd
catch "exec $cmd" exec_output
if [string match "" $exec_output] then {
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2022-09-28 13:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 4:34 Alan Modra
2022-09-28 13:31 ` Alan Modra [this message]
2022-09-28 20:25 ` Sam James
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=YzRMtuMy/waekpOU@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/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).