When delayed variable expansion is enabled, why do we require two escape characters for literal exclamation marks? ^^! vs ^!
I checked a lot of forums, and there's no explanation for it.
When delayed variable expansion is enabled, why do we require two escape characters for literal exclamation marks? ^^! vs ^!
I checked a lot of forums, and there's no explanation for it.
Referring to the thread How does the Windows Command Interpreter (CMD.EXE) parse scripts?, the reason for this is that there are two phases that support
^-escaping:^needs to be escaped as^^in order for a literal one to be passed over to further phases.^that reaches this point can be used to escape special characters, while there are only two such at this point, namely the exclamation mark!and the caret^;So, this results in the following behaviour:
Here is the resulting output: