incompatible environment variable names

Nellis, Kenneth Kenneth.Nellis@acs-inc.com
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:

C:\>set QNX_VISUAL_C++_PATH
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"
++_PATH
Cygwin> echo "$QNX_VISUAL_C++_PATH"
++_PATH
Cygwin> echo ${QNX_VISUAL_C++_PATH}

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

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
Cygwin>

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

--Ken Nellis


More information about the Cygwin mailing list