How does this work?

May 20, 2008
10,987
86
Syracuse, NY, USA
I can't figure out how this works but it manages to get an escape character into an environment variable in CMD.

1600393332484.png
 

samintz

Scott Mintz
May 20, 2008
1,462
14
Solon, OH, USA
The delims parameter delimits the text. So it parses the #$H#$E# into %%a==$H %%b=$E. But there is also no delayed expansion, so my guess is that the for %%b in (1) is essentially ignored. And the set ESC statement is working on the parsed token.
 
May 20, 2008
10,987
86
Syracuse, NY, USA
It looks to me like the first FOR is processing the output of the command

Code:
"prompt #$H#$E# & echo on & for %%b in (1) do rem"

Maybe I get it now. Because that command turns ECHO ON, the output of that command is (would be) the (new) prompt followed by the "rem". That would be #<backspace>#<esc>#rem and the outer FOR sets the variable ESC to the second token.

The surprising part is that the prompt itself is part of the (would-be) output of "prompt #$H#$E# & echo on & for %%b in (1) do rem".

[And maybe not.]
 
Thread starter Similar threads Forum Replies Date
Joe Caverly T&T - Miscellaneous 3