Closed DaveBenham closed 4 years ago
Have a look at the fix-call-caret
branch. I think it works, but if you could put it through its paces, that'd be great.
Seems to be working great.
A complex case like call call call echo a^^b"^c^d""e^f""^g"^^h""^^i"^j^k
gives the correct result of a^b"^c^d""e^f""^g"^h""^i"^j^k
Thanks
One of many serious design flaws of cmd.exe is how CALL will always double any quoted carets in the arguments. For example -
echo ^^"^"
properly yields^"^"
, but issuingcall echo ^^"^"
yields the undesired^"^^"
. There is no form of escaping that can avoid the doubling of the quoted carets.Workarounds are very cumbersome.
batch only
or
command line only
Each CALL causes the statement to go through an extra round of Phase 2 parsing, which consumes caret escapes. So some bonehead MS developer attempted to protect carets from the extra round of phase 2 by doubling them just prior to the extra round. But the code naively doubles all carets, instead of just the unquoted ones.
Can you implement a fix for this nasty design flaw? You are already intercepting CALL to implement extensions like
call @clear
. If your current intercept is after the carets have already been doubled, then I'm thinking it wouldn't be hard to scan the arguments and transform each quoted pair of carets to a single caret, but leave unquoted pairs alone.Obviously I'm assuming you have access to the CALL arguments, and are in a position to modify them.
If you are able to make this enhancement, then both
echo ^^"^"
andcall echo ^^"^"
would yield the same desired result:^"^"