incompatible environment variable names

Nellis, Kenneth
Wed Aug 4 16:24:00 GMT 2010

I came across an interesting (IMHO) incompatibility between 
Windows and bash environment variable names.

I have a Windows environment variable as such:

QNX_VISUAL_C++_PATH=C:\Program Files\Orbital Qnx VisualC++ IDE

So, Windows has no problem with + symbols in variable names, but
bash does, kinda sorta:

Cygwin> printenv QNX_VISUAL_C++_PATH
C:\Program Files\Orbital Qnx VisualC++ IDE
Cygwin> cygpath "$QNX_VISUAL_C++_PATH"
Cygwin> echo "$QNX_VISUAL_C++_PATH"
Cygwin> echo ${QNX_VISUAL_C++_PATH}

Cygwin> cygpath "$(printenv QNX_VISUAL_C++_PATH)"
/cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE

So, it seems that I can only access the value of the variable 
through printenv, and then cygpath does what I need, but I can't 
then assign it back to the environment variable:

Cygwin> export QNX_VISUAL_C++_PATH="$(cygpath "$(printenv QNX_VISUAL_C++_PATH)")"
-bash: export: `QNX_VISUAL_C++_PATH=/cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE': not a valid identifier

I probably need to give up on this, but felt like sharing my misery.

--Ken Nellis

More information about the Cygwin mailing list