[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [FYI] {master} maint: assume 'test -x' is portable
From: |
Peter Rosin |
Subject: |
Re: [FYI] {master} maint: assume 'test -x' is portable |
Date: |
Mon, 27 Feb 2012 15:51:14 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
Eric Blake skrev 2012-02-27 14:58:
> 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.
Note, this is all MSYS on NTFS, no FAT in sight.
>> $ 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
> issue.
>
> 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
$ ./gurka; echo $?
0
$ ls -lG gurka
-rw-r--r-- 1 peda 0 Feb 27 15:39 gurka
$ chmod +x gurka; echo $?
0
$ ls -lG gurka
-rw-r--r-- 1 peda 0 Feb 27 15:39 gurka
$ ./gurka; echo $?
0
$ echo paprika > gurka
$ ./gurka; echo $?
./gurka: line 1: paprika: command not found
127
$ rm gurka
$ echo "echo gurka" > gurka
$ ls -lG gurka
-rw-r--r-- 1 peda 11 Feb 27 15:49 gurka
$ ./gurka; echo $?
gurka
0
>> $ 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' > foo.sh
> ./foo.sh; echo $?
> test -x foo.sh; echo $?
> chmod a+x foo.sh; echo $?
> ./foo.sh; echo $?
> test -x foo.sh; 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.
$ test -x /; echo $?
0
$ test -x .; echo $?
0
$ printf '#!/bin/sh\nexit 0\n' > foo.sh
$ ./foo.sh; echo $?
0
$ test -x foo.sh; echo $?
0
$ chmod a+x foo.sh; echo $?
0
$ ./foo.sh; echo $?
0
$ test -x foo.sh; echo $?
0
Cheers,
Peter
- Re: [FYI] {master} maint: assume 'test -x' is portable, (continued)
Re: [FYI] {master} maint: assume 'test -x' is portable, Paul Eggert, 2012/02/23
Re: [FYI] {master} maint: assume 'test -x' is portable, Peter Rosin, 2012/02/26
Re: [FYI] {master} maint: assume 'test -x' is portable, Keith Marshall, 2012/02/27