[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Stepan Kasal
Subject: AS_EXECUTABLE_P again
Date: Thu, 20 Jan 2005 13:08:18 +0100
User-agent: Mutt/1.4.1i

I have an idea for another AS_EXECUTABLE_P improvement.  The following
explanation is somewhat complicated, but I couldn't help.

On systems supporting `test -x', AS_EXECUTABLE_P is

        { test -f $1 && test -x $1; }dnl

Let me remind, that test -x alone wouldn't be enough, because
it would succeed on a directory.

But this may cause problems on MS-DOS derivations.
Lets suppose that we have a file named foo.exe, but not foo.
Both DJGPP and Cygwin have extensions which cause `test -x foo' to succeed.
But `test -f' fails, so the whole AS_EXECUTABLE_P(foo) fails too.

One could think that

        { test -x $1 && test ! -d $1; }dnl

is better, because works equally well on Unices, but improves the above
situation.  AS_EXECUTABLE_P(foo) would succeed in the above situation. [1]

(There is no problem for autoconf itself, as it has
$ac_executable_extensions, but the improvement could be helpful for other
m4sh scripts.[2])

So, back to the above proposal:
1) Is `test -d' portable enough?  The manual doesn't say the contrary.

2) The autoconf manual says you cannot use `test ! -d' with `if'.
Which platforms have this problem?  Does it help if the test command is
embedded somehow?
In other words, would really both the following three examples fail
on that platform?

        if { test -x foo && test ! -d foo; }; then
                echo Yes.

        if ( test -x foo && test ! -d foo ); then
                echo Yes.

And if yes, wouldn't the following work?

        if { if test -d foo; then false; else test -x foo; fi; }; then
                echo Yes.

This would mean that AS_EXECUTABLE_P implementation would change to

        { if test -d $1; then false; else test -x $1; fi; }dnl

Looking forward to any comments,

[1] It would still fail if _both_ the file `foo.exe' and `foo' existed,
but it is less probable.
[2] Because of the situation described in [1], autoconf has to keep
$ac_executable_extensions, even if we improve the AS_EXECUTABLE_P macro.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]