Huidae Cho wrote:
> The main question is: in how many different places does this issue
> arise? If it's just Init.sh, we can add a hack for MSys. If it's going
> to keep cropping up, we need a more general solution.
Another problem is with the path separator.
PATH="c:/msys/1.0/.../grass/bin" does not work since it's translated to
PATH="c;c:\msys\1.0\msys\1.0\...\grass\bin". MSVCRT functions use the
c:/msys/1.0 syntax, but once modules are compiled, they need
PATH=/c/msys/1.0 to find DLLs.
MSys (bash) automatically translates filenames when it thinks that's
the correct thing to do, so you set PATH=/c/msys/1.0/.../grass/bin (or
just PATH=/.../grass/bin) and the program will actually get the
Windows syntax.
E.g.:
$ cat env.c
#include <stdio.h>
int main(void)
{
printf("%s\n", getenv("PATH"));
return 0;
}
$ echo $PATH
/usr/local/bin:/mingw/bin:/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem
$ ./env.exe
C:\msys\1.0\local\bin;c:\mingw\bin;C:\msys\1.0\bin;c:\WINDOWS\system32;c:\WINDOWS;c:\WINDOWS\System32\Wbem
The problem is that it can't always figure out if something is meant
to be translated or not. E.g. with:
echo "GISDBASE: $GISDBASE" > "$GISRC"
it doesn't treat the string as a filename, so it gets written
literally.
Some examples:
$ GISDBASE=/home/glynn/grass-data
$ echo $GISDBASE
/home/glynn/grass-data
$ /bin/echo $GISDBASE
/home/glynn/grass-data
$ ls -d $GISDBASE
/home/glynn/grass-data
$ /c/Cygwin/bin/ls.exe -d $GISDBASE
C:/msys/1.0/home/glynn/grass-data
$ /c/Cygwin/bin/echo.exe $GISDBASE
C:/msys/1.0/home/glynn/grass-data
$ /c/Cygwin/bin/echo.exe "GISDBASE:" $GISDBASE
GISDBASE: C:/msys/1.0/home/glynn/grass-data
$ /c/Cygwin/bin/echo.exe "GISDBASE: $GISDBASE"
GISDBASE: /home/glynn/grass-data
$ /c/Cygwin/bin/echo.exe foo=$GISDBASE
foo=C:/msys/1.0/home/glynn/grass-data
It appears that:
1. When calling a built-in, running a bash script (e.g. /bin/echo),
or running an MSys executable, no translation occurs.
2. When running a non-MSys executable (e.g. Cygwin's echo.exe or ls.exe),
translation is performed if a complete argument looks like a filename.
3. Where a filename is only part of an argument, translation may or
may not be performed depending upon the exact form of the argument. I
have no idea whether the specifics are documented anywhere.
So the issue comes down to determining cases where pathnames may
passed through mechanisms which aren't subject to the necessary
conversions (or possibly which are converted but shouldn't be).
--
Glynn Clements <glynn@gclements.plus.com>