Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2023-01-30 02:50:43
Size: 375
Comment:
Revision 3 as of 2023-01-30 03:12:02
Size: 1126
Comment:
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
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.
Line 25: Line 27:
If a string is quoted within double quotes (`"`), it is treated as a literal string. No [[Batch/Expansion|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 [[Shell/Quoting|Linux shell]] style...

{{{
set foo="foo \"bar\" baz"
}}}

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)