Subject: Re: bug#16380: Failing tests on Solaris in 2.16

From: Jim Meyering <[email-masked]>
Date: Tue, 7 Jan 2014 10:20:49 -0800

On Tue, Jan 7, 2014 at 12:29 AM, Dagobert Michelsen <[email-masked]> wrote:
> Hi,
>
> I have two failing tests for GNU grep 2.16 on Solaris 10 Sparc with Sun Studio 12:
>   http://buildfarm.opencsw.org/~dam/grep-2.16-test-suite.log
>
> Both boil down to the error
>
>   + /bin/sh ere.script
>   ere.script: syntax error at line 3: `status=$’ unexpected
>
> generated from bre.awk using the bashism
>
>   printf ("status=$(echo '%s' | { grep -e '%s' > /dev/null 2>&1; echo $? ; })\n",$3, $2);

Hi Dago,
Thanks for the report.
Does the attached patch fix it for you?
From 0e97186713815102b5b9780723cbb321da78462c Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Tue, 7 Jan 2014 10:19:00 -0800
Subject: [PATCH] tests: avoid a portability snag on Solaris 2.16

* tests/ere: Source the generated script, rather than exec'ing $SHELL,
and test the variable it sets.
* tests/ere.awk: Don't emit an "exit ..." at the end, since now
we're sourcing it, and not exec'ing the generated script.
Reported by Dagobert Michelsen in http://bugs.gnu.org/16380
---
 tests/ere     | 3 ++-
 tests/ere.awk | 2 --
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/ere b/tests/ere
index 04e6a75..005bff3 100755
--- a/tests/ere
+++ b/tests/ere
@@ -16,6 +16,7 @@ fail=0
 ${AWK-awk} -f $abs_top_srcdir/tests/ere.awk $abs_top_srcdir/tests/ere.tests \
   > ere.script || fail=1

-${SHELL-sh} ere.script || fail=1
+. ere.script
+test $failures = 1 && fail=1

 Exit $fail
diff --git a/tests/ere.awk b/tests/ere.awk
index 36f871e..4f36ff8 100644
--- a/tests/ere.awk
+++ b/tests/ere.awk
@@ -34,5 +34,3 @@ NF == 5 {
 # don't alarm the user for now
         next;
 }
-
-END { printf ("exit $failures\n"); }
-- 
1.8.5.2.229.g4448466