Reputation: 55786
There are a lot of questions on StackOverflow about how to escape a given character in cmd.exe
. However it seems that none of the solutions work in my case.
Basically, what I want to do is to set the environment variable FOO
to a!$5
.
I tried the obvious:
set FOO=a!$5
Which gives:
History expansion: set FOO=ae5
Fair enough, I guess I have to escape the !
or the $
, or both. However nothing seems to work.
I can do:
echo a^!
a!
And:
echo a$
a$
And even:
echo a^$
a$
But:
echo a^!$
History expansion: echo a^a^$
aa$
I'm at loss figuring out what to do here. It seems no matter how I escape the special characters, I can't get the result I want.
How can I do that ?
Upvotes: 0
Views: 80
Reputation: 55786
This is apparently a bug in Clink which I have set-up on my computers.
I ended-up doing the boring, yet working:
set FOO=a!
set FOO=%FOO%$5
Which works perfectly. Sad but at least it works for anyone.
Upvotes: 1
Reputation: 136
Not an answer, but when I type set FOO=a!$5, that's exactly what I get. I thought it might require a predecessor
Setlocal EnableDelayedExpansion
but it worked without doing that (perhaps it is my default?) Sorry I couldn't help!
Upvotes: 0