kastiglione created this revision. kastiglione added reviewers: clayborg, jingham.
Within .lldbinit, regex commands can be structured as a list of substitutions over multiple lines. It's possible that this is uninentional, but it works and has benefits. For example: command regex <command-name> s/pat1/repl1/ s/pat2/repl2/ ... I use this form of `command regex` in my `~/.lldbinit`, because it makes it clearer to write and read compared to a single line definition, because multiline substitutions don't need to be quoted, and are broken up one per line. However, multiline definitions result in usage instructions being printed for each use. The result is that every time I run `lldb`, I get a dozen or more lines of noise. With this change, the instructions are only printed when `command regex` is invoked interactively, or from a terminal, neither of which are true when lldb is sourcing `~/.lldbinit`. https://reviews.llvm.org/D48752 Files: packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py source/Commands/CommandObjectCommands.cpp Index: source/Commands/CommandObjectCommands.cpp =================================================================== --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -1009,9 +1009,12 @@ protected: void IOHandlerActivated(IOHandler &io_handler) override { + if (!io_handler.GetIsInteractive() && !io_handler.GetIsRealTerminal()) + // Don't print instructions during batch execution, such as .lldbinit. + return; StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) { - output_sp->PutCString("Enter one of more sed substitution commands in " + output_sp->PutCString("Enter one or more sed substitution commands in " "the form: 's/<regex>/<subst>/'.\nTerminate the " "substitution list with an empty line.\n"); output_sp->Flush(); Index: packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py +++ packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py @@ -24,7 +24,7 @@ """Test a simple scenario of 'command regex' invocation and subsequent use.""" import pexpect prompt = "(lldb) " - regex_prompt = "Enter one of more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n" + regex_prompt = "Enter one or more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n" regex_prompt1 = "\r\n" child = pexpect.spawn('%s %s' %
Index: source/Commands/CommandObjectCommands.cpp =================================================================== --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -1009,9 +1009,12 @@ protected: void IOHandlerActivated(IOHandler &io_handler) override { + if (!io_handler.GetIsInteractive() && !io_handler.GetIsRealTerminal()) + // Don't print instructions during batch execution, such as .lldbinit. + return; StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) { - output_sp->PutCString("Enter one of more sed substitution commands in " + output_sp->PutCString("Enter one or more sed substitution commands in " "the form: 's/<regex>/<subst>/'.\nTerminate the " "substitution list with an empty line.\n"); output_sp->Flush(); Index: packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py +++ packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py @@ -24,7 +24,7 @@ """Test a simple scenario of 'command regex' invocation and subsequent use.""" import pexpect prompt = "(lldb) " - regex_prompt = "Enter one of more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n" + regex_prompt = "Enter one or more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n" regex_prompt1 = "\r\n" child = pexpect.spawn('%s %s' %
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits