Re: [FYI] {master} maint: assume 'test -x' is portable

From:

Stefano Lattarini

Subject:

Re: [FYI] {master} maint: assume 'test -x' is portable

Date:

Fri, 24 Feb 2012 00:05:32 +0100

[Dropping automake-patches]
Hi Paul, sorry for stepping on your toes here, but ...
On 02/23/2012 11:59 PM, Paul Eggert wrote:
> It's been Quite Some Time since I've had to deal with
> 4.3BSD, or any host with a "test -x" problem, so I suggest
> the following patch to the Autoconf manual:
>
> [SNIP]
>
.. I was preparing a patch about this already, that also
took care of removing the workaround for missing "test -x"
in M4SH.
Autoconfers, WDYT?
Thanks,
Stefano
>From c5a8a69e15ad16b81031882334724df0a8456134 Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Stefano Lattarini <address@hidden>
Date: Thu, 23 Feb 2012 22:29:26 +0100
Subject: [PATCH] general: assume 'test -x' is portable today
* doc/autoconf.texi (@command{test} (files)): Don't tell that
'text -x' shouldn't be used; the only systems that lack it today
are museum pieces. Since we are at it, report known version of
Solaris whose /bin/sh doesn't grok 'test -e', rather than just
"hand-waving" to a generic Solaris system.
* lib/autoconf/m4sugar/m4sh.m4 (_AS_TEST_PREPARE): Just assume
that 'test -x' works. Adjust comments accordingly.
---
doc/autoconf.texi | 9 ++++-----
lib/m4sugar/m4sh.m4 | 35 ++++-------------------------------
2 files changed, 8 insertions(+), 36 deletions(-)
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 5c3feef..145788d 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -18126,11 +18126,10 @@ To enable @command{configure} scripts to support
cross-compilation, they
shouldn't do anything that tests features of the build system instead of
the host system. But occasionally you may find it necessary to check
whether some arbitrary file exists. To do so, use @samp{test -f} or
address@hidden -r}. Do not use @samp{test -x}, because 4.3BSD does not
-have it. Do not use @samp{test -e} either, because Solaris @command{/bin/sh}
-lacks it. To test for symbolic links on systems that have them, use
address@hidden -h} rather than @samp{test -L}; either form conforms to
-Posix 1003.1-2001, but older shells like Solaris 8
address@hidden -r}. Do not use @samp{test -e} either, because Solaris 10
address@hidden/bin/sh} lacks it. To test for symbolic links on systems that
+have them, use @samp{test -h} rather than @samp{test -L}; either form
+conforms to Posix 1003.1-2001, but older shells like Solaris 8
@code{/bin/sh} support only @option{-h}.
@item @command{test} (strings)
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 38e0bef..734bfd0 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1367,38 +1367,11 @@ esac[]])# AS_SET_CATFILE
# _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.
-#
+# This used to check whether `test -x' worked. Today, this should be
+# the case on all non-museum systems, so just assume it works.
+# FIXME: this macro should probably be removed in a future refactoring.
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
+[as_test_x='test -x'
dnl as_executable_p is present for backward compatibility with Libtool
dnl 1.5.22, but it should go away at some point.
as_executable_p=$as_test_x
--
1.7.9