Monday, January 11, 2010

Setting Environment Variables with Shell Script from within Cygwin

I experienced the Problem that within Cygwin Environment Variables were not set after the script finished even if I called "export".
For Expample the following Shell Script (my_environment.sh) didn't work.

#!/bin/sh
MY_VARIABLE="Hello"
export MY_VARIABLE
after calling the script, there was no error message, but an "ECHO $MY_VARIABLE" didn't output the expected result.
Within Cygwin you have to call the shell script the following way, to persist the resulting variables:
source my_environment.sh

No comments: