AS_EXECUTABLE_P again

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

 



Hi,
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.
	fi

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

And if yes, wouldn't the following work?

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

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,
	Stepan

[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.


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux