Hi Ed,
there are exactly three different caret phases.
The special character phase:
The caret escapes the next character and is removed, but works only outside of quotes.
Exclamation marks are not important at this phase.
The delayed phase
The caret escapes the next character, only important for exclamation marks, doesn't care about quotes.
AND this phase is only executed if there is at least on exclamation mark in the line.
The call phase:
All carets are doubled, don't care about quotes. This seems to be false, as you normally didn't see double quotes, but this is only, because they are normally removed by the next special character phase.
Samples
Code: Select all
setlocal enableDelayedExpansion
echo without exclam ^^^^ "^^^^"
echo with exclam ^^^^ "^^^^" !
set "^=one"
set "^^=two"
set "caret=^"
call echo %%!caret!%% caret
call call call call echo ^^^^ "^^^^"
Output
Code: Select all
without exclam ^^ "^^^^"
with exclam ^ "^^"
two caret
^^ "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
jeb