[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: Keith Marshall
Subject: Re: [FYI] {master} maint: assume 'test -x' is portable
Date: Mon, 27 Feb 2012 14:38:05 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20120131 Thunderbird/3.1.18

On 26/02/12 22:14, 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",

On the contrary...

> but I'm not sure what working is in this context...
> $ uname -a
> MINGW32_NT-6.1 PEDA-PC 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys

This tells me you are running MSYS on a recent MS-Windows system;
AFAIK, 'test -x' works correctly (as expected) on MSYS.

> $ touch gurka

Presumably creating an empty file.  No extension to mark it as
executable, and no content to shebang it, so...

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

...this is exactly as expected.

> $ test -x gurka.exe
> $ echo $?
> 1

Does gurka.exe exist?  If not, then this too is exactly as expected.

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

'chmod [-+]x ...' is a no-op in MSYS.  (Ignore Eric's FAT vs. NTFS red
herring; MS-Windows doesn't support executable attribute bits, so the
*only* way to mark a file as executable is by naming it with a suitable
extension, or, specific to MSYS, shebang it; this applies equally to FAT
and NTFS).  Here, gurka has neither a suitable extension, nor a shebang,
so it remains non-executable; again 'test -x' is working correctly, by
telling you this.

> $ test -x gurka.exe
> $ echo $?
> 1

You still don't have any gurka.exe, so 'test -x' is correct again.

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

Now, you've created an (empty) gurka.exe; by virtue of its extension, it
is considered executable.  In searching for a file which might be
executed when you enter the command

  $ ./gurka

MSYS emulates MS-Windows own behaviour when you specify a command name
with no explicit extension -- it can't match the unqualified name, so it
tries again with known executable extensions appended; it finds
gurka.exe, (which is executable), and correctly reports it so.

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

Correct again.

> $ chmod -x gurka.exe

Another no-op...

> $ test -x gurka
> $ echo $?
> 0 gurka (aka gurka.exe) remains executable, and this is again correct...

> $ test -x gurka.exe
> $ echo $?
> 0 is this.

It isn't 'test -x ...' that isn't working correctly here; it is your
understanding of MSYS, (and in particular the limitations of its chmod
command wrt file attributes which aren't supported by the underlying
MS-Windows OS), which is lacking.


reply via email to

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