[GRASS-dev] winGRASS: PATHEXT question
glynn at gclements.plus.com
Mon Dec 5 12:22:03 EST 2011
Martin Landa wrote:
> > If the .py extension is removed, bash will still recognise it as a
> > script via the shebang, but native Windows APIs won't be able to
> > execute it.
> I was thinking rather to "hide" the extensions, similarly to
> exe-files. In other words, when you type in console window
> the python script `r.buffer.py` will be launched. The user doesn't
> care if the module is an exe-file or python-script. Probably BAT
> script could help(?)
Only if MSys does some "magic" for BAT; Only EXE gets special
treatment from the OS. Specifically, if CreateProcess() is passed a
command line without a program, the first token in the command line is
taken as the program name. If the program name doesn't have an
extension, ".exe" is appended automatically. Any other extension (e.g.
.bat or .com) must be given explicitly. It's the shell (i.e. cmd.exe)
which uses PATHEXT to search for files with other extensions.
In any case, GRASS itself should be designed around the native
interfaces; on Windows, that means cmd.exe. Any support for MSys
should be done so as not to interfere with that. One option would be
to use shell aliases for scripts, i.e. "alias r.buffer=r.buffer.py".
Another would be to install shell scripts which execute the Python
script with its extension (i.e. the opposite of what we do for shell
scripts in 6.x).
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev