Reputation: 2017
I'm trying to set a secret key in my activate file for an anaconda environment on windows. The secret key contains special characters that need to be escaped (eg %
and ^
). Let's say the secret key literal is foobar%foo^bar%foo
. On the command line I can run:
SET SECRET_KEY=foobar^%foo^^^^bar^%foo
ECHO %SECRET_KEY%
And it returns foobar%foo^bar%foo
However in \etc\activate.d\env_vars.bat as described here I have the same line SET SECRET_KEY=foobar^%foo^^^^bar^%foo
, I activate the environment and run the ECHO %SECRET_KEY%
command and I get foobarfoo
returned.
Does anyone know how to escape the characters properly to get the correct string set in the environmental variable?
Windows 7 64-bit, Python 2.7, Conda 4.4.10
Upvotes: 1
Views: 709
Reputation: 5473
In the command line, the % sign can be escaped by %%, the ^ character with ^^ and then enclosing the string in "" ensures there are no special characters un-escaped. So, for foobar%foo^bar%foo
, the secret_key value should be escaped like:
set SECRET_KEY="foobar%%foo^^^^bar%%foo"
Upvotes: 2