kasi wrote:Triple quote can't work, because the bash parser always matches pairs of ".
Out of curiosity I just tried writing a command line parser function that worked the way I suggested... and quickly found myself climbing up my own posterior, so I guess that wasn't a good suggestion! Problem was infinite lookahead potentially required to resolve possible ambiguities.
The only set of rules I was able to implement without it becoming needlessly complicated was variations on what has already been discussed in this thread, i.e. arguments which need to be quoted (because they contain spaces) can be bracketed with either " or '. If the bracketed string must contain the qoute char then all occurrences of that char must be escaped with \.
So: "x y z" or 'x y z' are valid ways to bracket strings containing spaces, but no quote chars.
"x ' z" or 'x " z' is one way you can include quote chars without confusing the parser.
"x \" ' z" works when you can't avoid embedding a char that matches the quote char.
In fact it's possible to come up with an even simpler variant in which " is the only allowed quote char, and all embedded occurrences must be escaped... but if it was me I would implement the choice of quote chars for elegance, and because it costs almost nothing in code terms.
That makes my next suggestion :-
Code: Select all
VBoxManage guestcontrol win7 execute --username u --password u --image "c:\windows\system32\cmd.exe" -- /c start
"\"\\VBOXSVR\ws\a file.xlsx\""
Which (I've just checked) does not exactly match any suggestion already given.
Note that the escape char \ is not generic. Only a limited number of \x sequences would be supported (i.e. only \quotechar), anything else passes through unmodified, otherwise it makes a mess of Windows pathnames (we're back to having to use \\ for all path separators). And \ would certainly be the escape char I'd use.