diff options
author | Eric Blake <eblake@redhat.com> | 2012-02-24 21:09:34 -0700 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2012-02-24 21:46:26 -0700 |
commit | 8798792f568d7cdfb0815d249fe6a718d6877708 (patch) | |
tree | bc4292f3cb1d84b375e19bdf8ff5199898c1a38a | |
parent | fed83ed994ecc931769de2fa579ab4aec89028bd (diff) | |
download | autoconf-8798792f568d7cdfb0815d249fe6a718d6877708.tar.gz |
m4sh: require that 'test -x' works
4.3BSD is no longer a reasonable portability target; and we are
pretty sure that these days we can find at least one shell on any
platform that supports 'test -x'. Drop a horribly unsafe use of
eval as a result. :)
Libtool still uses $as_executable_p without so much as calling
either AS_TEST_X or AS_EXECUTABLE_P; even though the latter has
existed, although undocumented, since at least 2.59; furthermore,
libtool uses it in a context where filtering out directories
would have been desirable. Shame on them.
* lib/m4sugar/m4sh.m4 (_AS_TEST_X_WORKS): New probe.
(AS_SHELL_SANITIZE, AS_INIT): Use it in shell searching.
(AS_TEST_X, AS_EXECUTABLE_P): Simplify.
Signed-off-by: Eric Blake <eblake@redhat.com>
-rw-r--r-- | lib/m4sugar/m4sh.m4 | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 5d01f551..9cf1d071 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -513,6 +513,7 @@ m4_define([AS_SHELL_SANITIZE], m4_provide_if([AS_INIT], [], [m4_provide([AS_INIT]) _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK]) +_AS_DETECT_REQUIRED([_AS_TEST_X_WORKS]) _AS_DETECT_BETTER_SHELL _AS_UNSET_PREPARE ])]) @@ -1084,9 +1085,11 @@ fi # AS_TEST_X # --------- # Check whether a file has executable or search permissions. +# FIXME: This macro is no longer useful; consider deleting it in 2014 +# after we ensure m4sh scripts can always find a shell with test -x. m4_defun_init([AS_TEST_X], [AS_REQUIRE([_AS_TEST_PREPARE])], -[$as_test_x $1[]])# AS_TEST_X +[test -x $1[]])# AS_TEST_X # AS_EXECUTABLE_P @@ -1094,7 +1097,7 @@ m4_defun_init([AS_TEST_X], # Check whether a file is a regular file that has executable permissions. m4_defun_init([AS_EXECUTABLE_P], [AS_REQUIRE([_AS_TEST_PREPARE])], -[{ test -f $1 && AS_TEST_X([$1]); }])# AS_EXECUTABLE_P +[{ test -f $1 && test -x $1; }])# AS_EXECUTABLE_P # _AS_EXPR_PREPARE @@ -1365,42 +1368,17 @@ m4_define([AS_SET_CATFILE], esac[]])# AS_SET_CATFILE +# _AS_TEST_X_WORKS +# ---------------- +# These days, we require that `test -x' works. +m4_define([_AS_TEST_X_WORKS], [test -x /]) + # _AS_TEST_PREPARE # ---------------- -# Find out whether `test -x' works. If not, prepare a substitute -# that should work well enough for most scripts. -# -# Here are some of the problems with the substitute. -# The 'ls' tests whether the owner, not the current user, can execute/search. -# The eval means '*', '?', and '[' cause inadvertent file name globbing -# after the 'eval', so jam together as many tokens as we can to minimize -# the likelihood that the inadvertent globbing will actually do anything. -# Luckily, this gorp is needed only on really ancient hosts. -# +# Provide back-compat to people that hooked into our undocumented +# internals (here's looking at you, libtool). m4_defun([_AS_TEST_PREPARE], -[if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$[]1"; then - test -d "$[]1/."; - else - case $[]1 in @%:@( - -*)set "./$[]1";; - esac; - case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in @%:@(( - ???[[sx]]*):;;*)false;;esac;fi - '\'' sh - ' -fi -dnl as_executable_p is present for backward compatibility with Libtool -dnl 1.5.22, but it should go away at some point. +[as_test_x='test -x' as_executable_p=$as_test_x ])# _AS_TEST_PREPARE @@ -2177,5 +2155,6 @@ m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])]) m4_divert([BODY])dnl m4_text_box([Main body of script.]) _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl +_AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl ]) |