[Lldb-commits] [PATCH] Fix handling of backslashes in Args parsing
Zachary Turner
zturner at google.com
Tue Feb 24 07:43:53 PST 2015
Can you add a test with the examples you summarized? What does a\b generate
with this change?
On Tue, Feb 24, 2015 at 3:11 AM Pavel Labath <labath at google.com> wrote:
> Hi clayborg,
>
> Presently Args::SetCommandString allows quotes to be escaped with
> backslash. However, the
> backslash itself is not removed from the argument, nor there is a way to
> escape the backslash
> itself. This leads to surprising results:
>
> "a b" c" -> 'a b', 'c' # Here we actually have an unterminated quote,
> but that is ignored
> "a b\" c" -> 'a b\" c' # We try to escape the quote. That works but the
> backslash is not removed.
> "a b\\" c" -> 'a b\\" c' # Escaping the backslash has no effect.
>
> This change removes the possibility to escape the terminating quotes,
> making every quote run from
> one quote character to the next one. The contents for the quote are always
> taken literally, just
> like the single quotes in a posix shell. The only way to insert a literal
> quote character is to
> close the quote and then escape it with a backslash or to use a different
> kind of quotes.
>
> To summarize:
> "a b" c" -> 'a b', 'c' # unterminated quotes are still ignored
> "a b"\"" c" -> 'a b" c' # first way to insert a literal quote
> 'a b" c' -> 'a b" c' # second way to insert a literal quote
> "a b\" c -> 'a b\', c # backslash has no effect, we still get two
> arguments
> "a b\\" c -> 'a b\\', c # same here
>
> This change also removes some dead quote-handling code. This code
> (branching on the value of
> quote_char) was never executed since all quote handling was concentrated
> in the case '"': block,
> and the value was always set to 0 after exiting the block.
>
> http://reviews.llvm.org/D7855
>
> Files:
> source/Interpreter/Args.cpp
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150224/e5324c89/attachment.html>
More information about the lldb-commits
mailing list