I guess this one really can be blamed on Microsoft. :-)

That's one take on it. Here's another.

Under POSIX, -x determines if the file tested can be passed to exec(3) in order to load a new executable image into the current process.

By that criteria, only two of the four extensions you list ought to test as executable, because .cmd & .bat aren't binary image files, thus cannot be loaded directly as executable images. The other two are equivalent to (b|c|z)sh scripts which require execl("/bin/sh", "sh", "-c", command, (char *) 0) or similar to be run; ie. system.

The MSVCRT 'extension' of the POSIX definition of -x is a (perhaps silly) convenience from days of yore that's never been seen as important enough to rescind.

But then, the entire idea of the -x test on windows doesn't make a whole heap of sense as there is no such thing as the "executable" bit in Windows -- the permissions system is far more fine grained and extensive.

And, the concept of a files executability being defined by its extension a throwback to dos. An executable file can have any extension and it will still run:

C:\test>junk.exe as int: 9218868437227405313 as dbl: 1.#SNAN0 as dbl: 1.#QNAN0 as int: 9221120237041090561 C:\test>ren junk.exe junk.garbage C:\test>junk.garbage as int: 9218868437227405313 as dbl: 1.#SNAN0 as dbl: 1.#QNAN0 as int: 9221120237041090561

In reality, the mistake is that .cmd & .bat test as executable, not that .pl/.js/.whatever do not. It is the equivalent of *nix allowing you to pass a shell script filename to exec() and have it start the shell and then pass the script filename to it. (Ie. what system does.) And if you pass .pl/.js/.whatever (anything in pathext) to system on windows, it will execute them.

The bottom line is that you do not have to mark .cmd or .bat (or .exe or .com or .garbage) files executable, so there is no executable bit to test; so MSVCRT attempts to do something vaguely sensible as a substitute; but what was vaguely sensible all those years ago, perhaps looks less sensible now.

The bottom line is that where the two different worlds collide, there is no right solution; and whatever compromise is implemented it will be useful and convenient in one scenario and broken in another.

Similarly with the users/groups/network stuff. It isn't possible to map them transparently between OSs.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

In reply to Re^3: "executable suffixes" for -x on win32 (perlport) by BrowserUk
in thread "executable suffixes" for -x on win32 (perlport) by pryrt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.