bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr


From: Jim Meyering
Subject: Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr
Date: Wed, 08 Sep 2010 23:29:33 +0200

Eric Blake wrote:

> On 09/08/2010 03:17 PM, Jim Meyering wrote:
>>
>> +# Whether to reject a shell for which "set -x" corrupts stderr.
>> +strict_=yes
>> +
>> +gl_set_x_corrupts_stderr_='$( (exec 3>&1; set -x; P=1 true 2>&3) 2>  
>> /dev/null)'
>> +
>>   gl_shell_test_script_='
>>   test $(echo y) = y || exit 1
>> -test -z "$( (exec 3>&1; set -x; P=1 true 2>&3) 2>  /dev/null)" || exit 1
>> +if test $strict_ = yes&&  test -n "$gl_set_x_corrupts_stderr_"; then
>> +  exit 1
>> +fi
>
> Hmm - the value of $strict_ and $gl_set_x_corrupts_stderr_ are known
> to the parent shell, but not exported to the child shell.
>
>> +    for strict_ in yes no; do
>
> Reusing the same variable as you set earlier will leave $strict_ in
> the last state that it was in during the shell search.  Is that
> intended, or should you be iterating on a different variable name?
>
>> +      # Search for a shell that meets our requirements.
>> +      for re_shell_ in "${CONFIG_SHELL:-no_shell}" /bin/sh bash dash zsh 
>> pdksh
>> +      do
>> +        test "$re_shell_" = no_shell&&  continue
>> +        test "$re_shell_" = fail&&  skip_ failed to find an adequate shell
>> +        "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null
>
> You either need an eval on this line (to expand the embedded $strict_
> within $gl_shell_test_script_), or you need to export some variables.

Thanks for the quick review.
I noticed that one right away ;-)
Incremental below:

I'll address your other points after some sleep.

> Another thought - why do two passes?  Maybe a better option would be
> doing one pass, with two successful exit statuses (9 if the shell
> can't use set -x but otherwise works, 10 if the shell does both); then
> iterate until you either find a 10, or else pick the first shell that
> gave 9.


diff --git a/tests/init.sh b/tests/init.sh
index 690da63..8064495 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -287,7 +287,9 @@ setup_()
     # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5.
     # If enabling verbose output this way would cause trouble, simply
     # issue a warning and refrain.
-    if test -n "$gl_set_x_corrupts_stderr_"; then
+      set -x
+    gl_corrupt_=$(eval "$gl_set_x_corrupts_stderr_")
+    if test -n "$gl_corrupt_"; then
       warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr"
     else
       set -x



reply via email to

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