[Top][All Lists]
[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: |
Eric Blake |
Subject: |
Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr |
Date: |
Wed, 08 Sep 2010 15:24:07 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 |
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.
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.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
- [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Jim Meyering, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Eric Blake, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Jim Meyering, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Eric Blake, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Ralf Wildenhues, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Jim Meyering, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Jim Meyering, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr,
Eric Blake <=
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Jim Meyering, 2010/09/08
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Jim Meyering, 2010/09/09
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Eric Blake, 2010/09/09
- Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Bruce Korb, 2010/09/08
Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Stefano Lattarini, 2010/09/08
Re: [PATCH] init.sh: disqualify shells for which set -x corrupts stderr, Bruno Haible, 2010/09/08