Bruno Haible wrote: >> Now I've tried harder, and this does the job: > > Thanks a lot for getting to this so quickly! I can now single-step through > the test in the documented way. > > One line in the patch looks strange: In the test whether the current shell > is OK you test for an exit code 9; then in the loop you test for exit code 2. > In view of your comment about Solaris /bin/sh and exit code 2, I think you > meant the following: > > --- tests/init.sh.orig Sun May 16 21:50:43 2010 > +++ tests/init.sh Sun May 16 21:50:14 2010 > @@ -96,7 +96,8 @@ > 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 > - if test $? = 2; then > + if test $? = 9; then > + # Found a better shell than the current one. > exec "$re_shell_" "$0" --no-reexec "$@" > echo "$ME_: exec failed" 1>&2 > exit 127
Yes, definitely. Thank you. Here's what I've done: >From 1a183f8268eb1aae67bbc6bf65d98c703ac7983b Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Sun, 16 May 2010 22:30:00 +0200 Subject: [PATCH] init.sh: fix an error in the previous change; add more comments * tests/init.sh: Compare exit code in loop against 9, not 2. Patch by Bruno Haible. Make the two tests more similar by adding an empty "then" clause. Add comments. --- ChangeLog | 6 ++++++ tests/init.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea50e39..e7fbe0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-05-16 Jim Meyering <meyer...@redhat.com> + init.sh: fix an error in the previous change; add more comments + * tests/init.sh: Compare exit code in loop against 9, not 2. + Patch by Bruno Haible. + Make the two tests more similar by adding an empty "then" clause. + Add comments. + init.sh: avoid unnecessary shell re-exec * tests/init.sh: Improve the re-exec-required check to first test the current shell. If it passes the test, do not search for a shell that diff --git a/tests/init.sh b/tests/init.sh index 2ad385f..e23aa54 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -90,13 +90,17 @@ else # It does not evaluate any of the code after the "unexpected" `('. Thus, # we must run it in a subshell. ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 - if test $? != 9; then + if test $? = 9; then + : # The current shell is adequate. No re-exec required. + else + # Search for a shell that meets our requirements. for re_shell_ in "${CONFIG_SHELL:-no_shell}" /bin/sh bash dash zsh pdksh fail 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 - if test $? = 2; then + if test $? = 9; then + # Found an acceptable shell. exec "$re_shell_" "$0" --no-reexec "$@" echo "$ME_: exec failed" 1>&2 exit 127 -- 1.7.1.250.g7d1e8