Batch Quoting


Escaping Characters

Certain characters cause cmd.exe to interpret commands and arguments differently

These characters can be escaped to prevent their misinterpretation. The escape character is caret (^).

set foo=bar ^| baz

The primary challenge with escaping characters is that every time cmd.exe interprets an escaped character, the escape is removed. Commands that will be re-interpretted can require multiple escapes.


Quoting

If a string is quoted within double quotes ("), it is treated as a literal string. No expansion will apply to the value.

The double quote character might not be useable within a string quoted by souble quotes if it is escaped. It depends on how the command itself will parse arguments. Consult the specific commands to see if double quotes should be duplicated...

set foo="foo ""bar"" baz"

...or should be escaped in the Linux shell style...

set foo="foo \"bar\" baz"


CategoryRicottone

Batch/Quoting (last edited 2023-01-30 03:12:02 by DominicRicottone)