Expression of characters in a variable name

Can anyone explain how cmd handles carats in the following examples?

C:\>set ^^=test

C:\>echo %^%
test

C:\>echo ^%^%
test

C:\>echo %^^%
%^%

I realized that it %^%would be handled as simple as that %%. I assume that variable expansion is processed before the carat is considered, however this is a half-put answer to the question, which, I am sure, could be more eloquently explained.

In batch mode -

@echo off
set ^^=test
echo %^%
echo ^%^%
echo %^^%

-

C:\>test.bat
test
test
ECHO is off.
+4
source share
2 answers

, . , . escape-. %% ^.

/

1) ( ):

  • %% %
  • (%1, %2 ..)
  • %var%, var , .
  • dbenham :

1.5) <CR> (CarriageReturn 0x0d)

2) ( , " <LF> ^ & | < > ( ):

  • ("), , , : ^ & | < > ( ).
  • (^), , , , , .
    • <LF> ,

( !) . :

+3

...

^, set ^^=test.

, - , , <CR>, , .
( , ), mutliline caret .

echo %va^
r%

set "^=one caret"
set "^^=two carets"
echo "%^%"
call echo "%%^%%"

"one caret"
"two carets"

, CALL

+3

Source: https://habr.com/ru/post/1534942/


All Articles