C:\>echo a | grep "\""
C:\>echo a | grep "\"" >g
grep: >g: No such file or directory
C:\>
It looks to me, and please correct me if i'm wrong, it looks like the formulation
of
" \" " <--- should be avoided - at least in I suppose any program that uses argsv, as it leads to a mismatch of quotes.
Though to escape a quote, this is fine """ And \"(without quotes around it) is fine.
Another thing that doesn't work with an argsv program, is ^" (though it's fine as an argument for echo which uses GetCommandLine)
C:\>echo a | grep "^"" >g
grep: >g: No such file or directory
so in the sense of tripping that error, it's like "\""
But ^" produces strange results with grep or any argsv program.
For example, if ^" behaved, then this shouldn't return anything.
Code: Select all
C:\>echo a| grep ^"
a
C:\>
I think it causes grep's argsv[1] to exist but with i'm not sure what in it. Multiple ^" are also strange.
But it seems to be the way to escape a quote when it's an argument to echo
Code: Select all
C:\>echo "f | grep "f"
"f | grep "f"
C:\>echo ^"f | grep "f"
"f
C:\>echo \"f | grep "f"
\"f | grep "f"
C:\>
So for example
this works
Code: Select all
C:\>echo ^"f|grep \">g
Using \" works with an argsv program.
C:\>echo "f|grep f
"f|grep f
When one has an odd number of quotes as part of the echo, then one has to escape one or more if one wants to, so they're even in number.
C:\>echo \"f|grep f
\"f|grep f
(a \" with echo fails as echo is a GetCommandLine program so don't use it with echo!)
C:\>
C:\>echo ^"f|grep \"f
"f
Use ^" with echo as echo uses GetCommandLine
C:\>
Does anybody have any thoughts on what's happening?