[Top][All Lists]

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

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

From: Eric Blake
Subject: Re: [FYI] {master} maint: assume 'test -x' is portable
Date: Mon, 27 Feb 2012 06:58:18 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1

On 02/26/2012 03:14 PM, Peter Rosin wrote:

> Sorry for the late reply, but this might be relevant.  Personally, I wouldn't
> classify the below as a working "test -x", but I'm not sure what working is in
> this context...

Thanks for chiming in.  I still haven't pushed my proposed patches to
autoconf, and I'd like to make sure that what I'm proposing for autoconf
still gets by on your MSYS system (I don't have MSYS set up myself, so
getting feedback from you would be fastest).  I assume that some of MSYS
behavior on FAT is similar to cygwin on FAT, and I have been testing
Cygwin on FAT, but I also know that Cygwin and MSYS have diverged so
that is not necessarily a reliable result.

> $ uname -a
> MINGW32_NT-6.1 PEDA-PC 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
> $ touch gurka
> $ test -x gurka
> $ echo $?
> 1

This says an empty file is not executable.  Fine - there's no #! in the
file, and MSYS tends to store files on FAT filesystems that can't track
real permissions, anyway, so faking things based on contents is not an

What does './gurka; echo $?' do in this situation?

> $ chmod +x gurka
> $ test -x gurka
> $ echo $?
> 1

You didn't show $? nor 'ls -l' after 'chmod +x', but your transcript
implies that since the filesystem can't record executable bits, that
chmod is silently ignored, and the faking of executability is still
being done.

> $ touch gurka.exe
> $ test -x gurka
> $ echo $?
> 0

This says part of the faking is done via file extension (although an
empty length .exe should never occur in practice).

I'm also interested in the behavior of the following (which is what I
have proposed that autoconf adds to all configure scripts, and will fail
if it cannot find a shell that claims to work):

test -x /; echo $?
test -x .; echo $?
printf '#!/bin/sh\nexit 0\n' >
./; echo $?
test -x; echo $?
chmod a+x; echo $?
./; echo $?
test -x; echo $?

Once I know those behaviors, I think I can ensure that my proposed test
to require a "working" 'test -x' as a pre-req of finding a sane shell
should still work for MSYS.

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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