This is the mail archive of the
mailing list for the Cygwin project.
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 "edit.com %*" (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 edit.com rather
than foo.bat being run).
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple