bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exclude tests refactoring


From: Jim Meyering
Subject: Re: exclude tests refactoring
Date: Sun, 13 Nov 2011 21:42:48 +0100

Bruno Haible wrote:
> Hi Jim,
>
>> Thanks for testing and noticing that.
>> However, I would like to avoid using a temporary file when using GNU diff.
>> How about something like this instead?
>>
>> diff_=$(diff -u "$0" "$0" < /dev/null 2> /dev/null)
>> if test $? = 0; then
>>   if test -z "$diff_"; then
>>     compare () { diff -u "$@"; }
>>   else
>>     ...
>>   fi
>> elif ...
>
> OK, I modified and applied the patch like this.
>
> Note that with use of $(...) outside double-quotes, namely
>
>   diff_out_=$( ( diff -u "$0" "$0" < /dev/null ) 2>/dev/null)
>
> I got a syntax error on OSF/1 and Solaris:
>
> ./test-exclude1.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude1.sh
> ./test-exclude2.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude2.sh
> ./test-exclude3.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude3.sh
> ./test-exclude4.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude4.sh
> ./test-exclude5.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude5.sh
> ./test-exclude6.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude6.sh
> ./test-exclude7.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude7.sh
> ./test-exclude8.sh: syntax error at line 224: `diff_out_=$' unexpected
> FAIL: test-exclude8.sh
>
> The reexec magic, which comes earlier in this file, would print debugging
> output like this:
>
>   __current__ works just fine
>   /bin/sh works just fine
>   bash works just fine
>   exec bash ./test-exclude1.sh --no-reexec
>   PASS: test-exclude1.sh
>
> but when the
>
>    diff_out_=$( ( diff -u "$0" "$0" < /dev/null ) 2>/dev/null)

I'm glad you discovered that.
That Solaris /bin/sh behavior is particularly aggravating.

The whole point of re-exec'ing was to avoid exposure to that.
This makes me think that the re-exec'ing script needs to
be separate from the rest.

> line is present, the execution does not even get that far. Apparently the
> parts of init.sh that are parsed by the initial shell (I tried /bin/sh
> and /bin/ksh) extend beyond the point of execution; possibly it includes
> the entire init.sh file.
>
> I could have written
>
>    diff_out_="$( ( diff -u "$0" "$0" < /dev/null ) 2>/dev/null)"
>
> This does not produce a parse error. But it is nevertheless quite dangerous
> to let the initial shell parse a piece of code incorrectly, even if we know
> that we will jump out of this shell before the incorrectly parsed code can
> be executed.
>
>
> 2011-11-13  Bruno Haible  <address@hidden>
>           Jim Meyering  <address@hidden>
>
>       Silence successful tests that use 'compare' on AIX, HP-UX, Solaris.
>       * tests/init.sh (compare): Remove "No differences encountered" or
>       synonymous output from the 'diff' program.

Thanks!
That should do the job.
If I'd known you were doing that right now I would have delayed
today's grep snapshot by 5 or 10 minutes to include it ;-)
Oh well.  I'll update from gnulib again before the release.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]