Getting Cygwin working with strange environments
Cygwin’s bash usually just works — it gets the environment settings from the system (much like cmd does) and then you have it when the prompt starts up.
But sometimes don’t get that — the system you want to use comes with a batch file that sets up the environment and, in order for you to use those variables, etc, you have to use their cmd — what what if you want to use that environment at your bash prompt instead?
There are really two ways to set this up — depending on your environment. Here are two examples that I have set up on my workstation.
Setting up .Net 2.0 SDK
The .Net SDK creates a cmd prompt that simply defines a number of environment variables so you can compile and execute your .Net applications. The cmd that is created is simply called from a batch file — when you click on the “SDK Command Prompt” in your start menu, it just called a batch file that defines those environment variables.
Getting this into bash is really quite easy — just put the following in your ~/.bashrc:
`cygpath -u c:/PROGRA~1/MICROS~1.NET/SDK/v2.0/Bin/sdkvars.bat`
Note that I used the short path of sdkvars.bat and usedcygpath
to get the Cygwin path of sdkvars.bat.
Setting up DB2
I have DB2 setup on my workstation and it has a similar thing — it is called Command Window but it’s really just a cmd with several environment variables setup. Upon close inspection, though, simply setting those environment variables doesn’t to the job. When I took a peak in db2cw.bat, I noted that it ran a program first but I also noticed that db2cw.bat took arguments.
So now my Cygwin shortcut is:
C:\Program Files\IBM\SQLLIB\BIN\db2cw.bat C:\DOCUME~1\HOSTET~1\bin\rxvt.bat
Note that I’m using the short name of my rxvt.bat — for some reason, cmd doesn’t like spaces in arguments — go figure.