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   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to