[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] More changes to the better-shell test
From: |
Paolo Bonzini |
Subject: |
[PATCH] More changes to the better-shell test |
Date: |
Thu, 30 Oct 2008 10:27:59 +0100 |
User-agent: |
Thunderbird 2.0.0.17 (Macintosh/20080914) |
The better-shell test on these two scripts:
AS_INIT
_AS_DETECT_SUGGESTED([/bin/false])
AS_INIT
_AS_DETECT_SUGGESTED([echo abc >> blah; test "`cat blah`" != abc])
takes 0.43s and 0.16s on my computer (the second script should be
invoked after a "rm blah").
The attached patches reduce it respectively to 0.40s and 0.15s (the
difference is consistent across many runs for the second test too:
1) avoiding a walk of the entire PATH is one of the first shells passes
the test (patches 1-2);
2) not running the suggested tests for $SHELL in case we reach that
point (patch 2);
In addition, I noticed that _AS_CR_PREPARE is useless in most scripts.
I checked that Libtool does not use the as_cr_* variables that it sets,
either.
I checked that "break N" was in the original Bourne-shell distributed at
http://www.in-ulm.de/~mascheck/bourne/ (that's more or less the
30-year-old v7 shell)
Ok?
Paolo
commit 3fb0b9566748e8ade6fc22e3e7b9ab71fdfcc5c1
Author: Paolo Bonzini <address@hidden>
Date: Thu Oct 30 09:51:32 2008 +0100
Add third argument to _AS_PATH_WALK
* lib/m4sugar/m4sh.m4 (_AS_SHELL_SANITIZE): Do not call _AS_CR_PREPARE.
(_AS_PATH_WALK): Add third optional argument.
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 22e7e3e..3eac1a8 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -435,9 +435,6 @@ m4_defun([_AS_SHELL_SANITIZE],
[m4_text_box([M4sh Initialization.])
AS_BOURNE_COMPATIBLE
-
-# PATH needs CR
-_AS_CR_PREPARE
_AS_ECHO_PREPARE
_AS_PATH_SEPARATOR_PREPARE
@@ -1154,9 +1151,10 @@ fi
])# _AS_PATH_SEPARATOR_PREPARE
-# _AS_PATH_WALK([PATH = $PATH], BODY)
-# -----------------------------------
-# Walk through PATH running BODY for each `as_dir'.
+# _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
+# ---------------------------------------------------
+# Walk through PATH running BODY for each `as_dir'. If BODY never does a
+# `break', evaluate IF-NOT-FOUND.
#
# Still very private as its interface looks quite bad.
#
@@ -1168,6 +1166,7 @@ fi
m4_defun_init([_AS_PATH_WALK],
[AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
[as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+m4_ifvaln([$3], [as_found=false])dnl
m4_bmatch([$1], [[:;]],
[as_dummy="$1"
for as_dir in $as_dummy],
@@ -1175,8 +1174,11 @@ for as_dir in $as_dummy],
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
+ m4_ifvaln([$3], [as_found=:])dnl
$2
+ m4_ifvaln([$3], [as_found=false])dnl
done
+m4_ifvaln([$3], [$as_found || { $3; }])dnl
IFS=$as_save_IFS
])
commit c29ca1d13b98eb1791ba5b7365327c91ccca6c13
Author: Paolo Bonzini <address@hidden>
Date: Thu Oct 30 09:52:22 2008 +0100
Avoid walking the entire PATH when looking for a better shell.
* lib/m4sugar/m4sh.m4 (_AS_SHELL_SANITIZE): Test shell characteristics
as the PATH is walked.
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 3eac1a8..1416587 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -221,24 +221,23 @@ dnl Remove any tests from suggested that are also required
[as_have_required=no])
AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
[],
- [as_candidate_shells=
- _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
+ [_AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
[case $as_dir in @%:@(
/*)
for as_base in sh bash ksh sh5; do
- as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+ # Try only shells that exist, to save several forks.
+ as_shell=$as_dir/$as_base
+ AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ _AS_RUN(["$as_required"], ["$as_shell"])],
+ [CONFIG_SHELL=$as_shell as_have_required=yes
+ m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break 2],
+ [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
+ [break 2])])])
done;;
- esac])
-
- for as_shell in $as_candidate_shells $SHELL; do
- # Try only shells that exist, to save several forks.
- AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
- _AS_RUN(["$as_required"], ["$as_shell"])],
- [CONFIG_SHELL=$as_shell
- as_have_required=yes
- m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break],
- [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
[break])])])
- done
+ esac],
+ [AS_IF([{ test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+ _AS_RUN(["$as_required"], ["$SHELL"])],
+ [CONFIG_SHELL=$SHELL as_have_required=yes])])
AS_IF([test "x$CONFIG_SHELL" != x],
[# We cannot yet assume a decent shell, so we have to provide a
- [PATCH] More changes to the better-shell test,
Paolo Bonzini <=