3 May 2011 23:55
path string differences
I did some testing and found threads on the MINGW/MSYS mail lists that
helped me figure out a fairly simple solution.
All I needed to do was change the working directory for the current
process into the same format returned by $(cd "$BLDROOT"; pwd),
which could be either an MSYS canonical or a mount rooted path.
So for example, say the user set BLDROOT="C:\msys\1.0\user\joe\src" as
a system environment variable. Then the user opens a bash shell and cd's
to the src folder.
The following bash code would work regardless of how the user got to the
src folder, some examples:
$ cd "C:\msys\1.0\home\joe" # pwd would yield /mingw/msys/1.0/home/joe
$ cd "/c/msys/1.0/home/joe" # pwd would yield /c/mingw/msys/1.0/home/joe
$ cd ~/src # pwd would yield /home/joe/src
$ cd /home/joe/src # pwd would yield /home/joe/src
---- bash code snippet, lots of code omitted ---------
if [[ $OSTYPE == msys ]]; then
if (ls -d "$BLDROOT" 2>/dev/null); then
BLDROOT=$(cd "$BLDROOT" && pwd | tr '[:upper:]' '[:lower:]')
cd `pwd -W`
fi
fi
DIR1=$(cd ..; pwd) # could return either an MSYS canonical or a mount rooted path
DIR2=$(cd "$BLDROOT"; pwd) # if BLDROOT lives in MinGW or msys folder
(Continue reading)
RSS Feed