Open DanielG opened 8 years ago
Note that literal backslashes and double quotes should be backslash-escaped, and not only in filenames, but in symbols as well.
One example where #703 breaks compatibility is info
for \\
operator. \\
will be parsed as literal \
.
Backslash escaping space seems like a bad idea due to the example you mention. Can you remove that bit? Having to backslash escape "
is fine in my mind tough.
Last example is not due to escaping spaces, but rather due to escaping backslashes themselves.
Consider getting info
for operator \\
, for example. If you would pass
info "src/Module.hs" "\\"
Then without backslash-escapes, last quote would be interpreted as literal quote.
So.. yeah. Backslashes have to be escaped. Might consider using another symbol for escaping, though (\ESC
?)
Ah yes of course that's no good either. How about adding an option to all commands to selectively turn on quoting? Splitting the command on all spaces first, then checking if say --escape
is the second argument and then parsing it again with quoting enabled should work.
So you could have info --escape "src/Foo.hs" "\\\\"
since the frontend would have to know about the double escaping but still support the old format.
Maybe having the option as the second argument is a bad idea since that will conflict with filenames that used to work in theory, so maybe have --escape be at the end or before the command even or something? Whatever you think works.
What if we actually use \ESC
as an escape symbol though, i.e. ASCII symbol 0x1b
? I don't think it can be used in filenames or Haskell identifiers. Literal double-quotes can still pose a problem though.
Or, better yet, use \STX
and \ETX
instead of quotes?
Actually, yes, now that I think about it, ASCII characters \STX
and \ETX
(i.e. 0x02
and 0x03
) should work fine as 'start of quoted fragment' and 'end of quoted fragment'. Then escaping characters becomes a moot point.
Also, quoted \STX
is a literal \STX
, and if one needs to include literal \ETX
, it can be included as \ETX\ETX\STX
inside quoted segment. I really doubt it's a valid use-case though.
703 added support for quoted filenames, yey.