in reply to Parsing Windows CommandLine from Perl
The Relevant one for this issue is:
Any double-quote directly following a closing quote is treated as (or as part of) plain unwrapped text that is adjacent to the double-quoted group, but only one double-quote:You seem to want to send the 2 middle double-quotes as a part of one single parameter.
"Tim says, ""Hi!""" will act as one parameter: Tim says, "Hi!"
I cannot claim to understand how c manages to get access to, and interpret the parameters without the cmd interpreter's intervention.perl arg.pl "abc """""" xyz"
Update:This link goes into depth to explain how WIndows command lines are processed. It answered my doubts on why the C code behaved differently:
The C/C++ compiler which compiles the program secretly adds extra code to the executable that retrieves and parses the command line to extract the parameters before calling WinMain (or main). Thus, for a C/C++ executable on Windows, the parameter parsing rules are determined by the C/C++ compiler that compiled the program.and has this little gem:
The missing undocumented rule has to do with how doubledouble quotes ("") are handled:Anyway - I prefer fishmonger's answer below, which reflects the rule:Prior to 2008:
If a closing " is followed immediately by another ", the 2nd " is accepted literally and added to the parameter.
After 2008
A double quote encountered outside a double quoted block starts a double quoted block.
A double quote encountered inside a double quoted block:
* not followed by another double quote ends the double quoted block.
* followed immediately by another double quote (e.g. ""), a single double quote is added to the output, and the double quoted block continues.
Use \" to insert a literal "
"You're only given one little spark of madness. You mustn't lose it." - Robin Williams
|
|---|