But the Julia version of that line fails, as does every other combination I’ve tried using single quotes, double quotes and backslashes. It just opens the truncated url https://www.google.com/maps?t=k.
julia> run(`cmd /c start "" "http://maps.google.com/maps?t=k&q=loc:51.508062+-0.076051"`)
'q' is not recognized as an internal or external command,
operable program or batch file.
ERROR: failed process: Process(`cmd /c start '' 'http://maps.google.com/maps?t=k&q=loc:51.508062+-0.076051'`, ProcessExited(1)) [1]
So how can I run that call to Google maps from Julia?
I’m used to all the backslashes since I have plenty of experience with regexes, but this was really unusual. This is what you get if you print the c variable that you create:
julia> c
`cmd /c start '""' 'http://maps.google.com/maps?t=k"&"q=loc:51.508062+-0.076051'`
It seems that the ampersand was escaped by surrounding it with double-quotes in the middle of a single-quoted string. That’s what I found so bizarre. Is that a Windows requirement? Anyway, I wouldn’t have figured out that syntax in a million years so all the more power to you.
So my guess was, that the surrounding " aren’t passed with the arguments so some special quoting needs to be done.
The next steps were just trail and error with some implausible imagination
The real issue here is, that the next time someone looks for proper quoting, this solution here may not help at all, because c.exec is identical with or without windows_verbatim=true. The difference is in c.flags:
julia> c.flags
0x00000004
and setting windows_verbatim=true seems to be contra-intuitive:
help?> Cmd
...
• windows_verbatim::Bool: If true (defaults to false), then on Windows the Cmd will send a command-line string to the
process with no quoting or escaping of arguments, even arguments containing spaces...
So looking for proper quoting the default false makes more sense, but I didn’t found a way with that.