how do you explain this with escaping quotes in cmd
Posted: 13 Aug 2022 15:19
I would have thought that of these quotes
The first one has special meaning
The second one is attempted to be escaped
The third one is attempted to be escaped
The fourth one has special meaning and is paired with the first one. (Or turns the special meaning created by the first one, off).
Turns out the second one didn't get escaped. Got treated as special, so turned off the quoting So the third one at least got escaped..
Is it even possible to escape a quote when the special quoting meaning is on..
So, after the first quote, special meaning of quotes is On. So then ^ doesn't escape anything and gets sent literally. And the second quote ends up closing the special meaning.
What I was intending was, Turn quoting on and write a quote (that's for the first quote, that worked). Then write zzz. Then I intended that the second quote is escaped and wouldn't turn off the special meaning of quotes. Then I intended for abc to be written. And then (with special meaning still on), escape a quote(the third quote). Then print a quote(fourth quote). that also has special meaning and turns quoting off.
I see it doesn't work like that.. which makes me wonder..
Is it possible to have a literal quote within quotes?
I thought this might
and maybe it does, but that needs 3 quotes one after the other.
but if I want to say a b c " d e f as one argument.. I need quotes around the 7 characters, and I need the middle quote to be literal.
Can that be done?
Code: Select all
C:\>echo "zzz^"abc^""
"zzz^"abc""
C:\>
Code: Select all
echo "zzz^"abc^""
quotes 1,2,3,4
1- the quote before the zzz
2- between the zzz and the abc there is a ^" So the quote there.
3- after the abc there is ^" , the quote there.
4- There is a quote at the end
The first one has special meaning
The second one is attempted to be escaped
The third one is attempted to be escaped
The fourth one has special meaning and is paired with the first one. (Or turns the special meaning created by the first one, off).
Turns out the second one didn't get escaped. Got treated as special, so turned off the quoting So the third one at least got escaped..
Is it even possible to escape a quote when the special quoting meaning is on..
So, after the first quote, special meaning of quotes is On. So then ^ doesn't escape anything and gets sent literally. And the second quote ends up closing the special meaning.
What I was intending was, Turn quoting on and write a quote (that's for the first quote, that worked). Then write zzz. Then I intended that the second quote is escaped and wouldn't turn off the special meaning of quotes. Then I intended for abc to be written. And then (with special meaning still on), escape a quote(the third quote). Then print a quote(fourth quote). that also has special meaning and turns quoting off.
I see it doesn't work like that.. which makes me wonder..
Is it possible to have a literal quote within quotes?
I thought this might
Code: Select all
C:\>echo """
"""
but if I want to say a b c " d e f as one argument.. I need quotes around the 7 characters, and I need the middle quote to be literal.
Can that be done?