<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">backtick parsing is currently incorrect, because it parses the backtick before doing arg parsing, which means it does the substitutions for “raw” commands:<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(lldb) expr char *$foo = "some `1 + 2` string"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(lldb) expr $foo</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(char *) $foo = 0x000000010032f100 "some 3 string"</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">That’s unexpected, and since part of the point of expr is that you can freely cut and paste from a source view into the expr command, it is not desirable.</div><div class=""><br class=""></div><div class=""><div class="">The most straightforward way to fix this is to make backtick parsing happen as a part of argument parsing - so you would know you were in a raw command and not intervene in the input.</div><div class=""><br class=""></div><div class="">I actually think the full bash quoting rules are overly complex for lldb. Greg was having fun emulating the bash syntax but that seems an unnecessarily complex model for lldb’s command line. But that may be water under the bridge at this point.</div><div class=""><br class=""></div><div class="">Jim</div><div class=""><br class=""></div><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Nov 22, 2016, at 2:59 AM, Pavel Labath <<a href="mailto:labath@google.com" class="">labath@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">labath added a comment.<br class=""><br class="">In <a href="https://reviews.llvm.org/D26883#601638" class="">https://reviews.llvm.org/D26883#601638</a>, @jingham wrote:<br class=""><br class=""><blockquote type="cite" class="">The outermost quote character is syntactically significant in the lldb command language. If you say:<br class=""><br class="">memory read -c `count_var` 0x123345<br class=""><br class="">then lldb evaluates the expression in the backticks, replacing the argument with the result of the expression. So you can't get rid of the quote character altogether. The other use is in completion to figure out what an unterminated quoted string should be completed with.<br class=""><br class="">Since only the outermost quoting character is important, I think the problem is more tractable than your examples would suggest.<br class=""></blockquote><br class=""><br class="">I didn't mention backticks, as (to use bash parlor) command substitution and word splitting are two separate passes. backticks can be embedded into a single word, which also contains other kinds of quote characters, so storing the quote character alongside the word-split argument is not going to help you implement command substitution. LLDB actually handles this mostly correctly now (notice that in each case the input gets parsed as a single word):<br class=""><br class=""> (lldb) `1+1`<br class=""> error: '2' is not a valid command.<br class=""> error: Unrecognized command '2'.<br class=""> (lldb) a`1+1`a<br class=""> error: 'a2a' is not a valid command.<br class=""> error: Unrecognized command 'a2a'.<br class=""> (lldb) `1+1`a`2+2`<br class=""> error: '2a4' is not a valid command.<br class=""> error: Unrecognized command '2a4'.<br class=""> (lldb) "a a"`1+1`"b a"<br class=""> error: unknown command shorthand suffix: ' a'<br class=""> error: Unrecognized command 'a a2b a'.<br class=""><br class="">The reason this works is because the command substitution is done in a different place in the code, so I still hold my view that the Args class does not need to differentiate between the different quote characters as it is just a holder for a word-split input.<br class=""><br class="">That said, none of this should affect this patch. If the quote char field has been there until now, it can stay a little longer.<br class=""><br class=""><br class="">Repository:<br class=""> rL LLVM<br class=""><br class=""><a href="https://reviews.llvm.org/D26883" class="">https://reviews.llvm.org/D26883</a><br class=""><br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></div></div></div></body></html>