This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATHEXT is fundamental to Windows and Should be recognised by CYGWIN

On Tue, Aug 9, 2016 at 9:01 PM, Andrey Repin wrote:
> Greetings, Erik Soderquist!
>> PATHEXT looks for *executable* files, not file association.  I warned
>> previously in this thread about getting the two confused.
> Your statement is confusing. If not contradictory.
> PATHEXT tells the shell to consider these file extensions executable.
> If you create a file association for ".sh" and add ".SH" to pathext, CMD will
> happily execute it, and in the current console.

PATHEXT is very simply a list of extensions CMD.EXE will automatically
append to the given filename when searching the PATH for a command to
execute.  Once a filename+extension is found, CMD.EXE still needs to
know what to do with the given file to be able to execute it.

In the case of .bat and .cmd files, CMD.EXE knows these are lists of
commands to be executed in order.

In the case of .exe files, CMD.EXE knows that these files are
executable unto themselves.

When CMD.EXE finds a file with an extension in the PATHEXT list to
match the extension-less request, it considers the search for the
requested command complete, and at this point PATHEXT has served its
purpose.  CMD.EXE then looks to the execution of the command, and this
is where File Associations come in when the extension is not already
natively known to CMD.EXE, and are a partial equivalent to *nix's #!
line in script files.  For example, .VBS is considered executeable,
but CMD.EXE has to look up under File Associations *how* to execute
it.   (I do not remember exactly how, but to prove a point years ago,
I modified my registry so that .txt was considered 'executable' in the
same way .VBS is, and the execute method was " %*" (I think).
This had very annoying results since I also put .txt as the first
extension for PATHEXT, and so foo.txt was opened in rather
than foo.bat being run).

-- Erik

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]