diff options
| author | Jim Ingham <jingham@apple.com> | 2018-12-21 01:45:28 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2018-12-21 01:45:28 +0000 |
| commit | 79d8105fc80b866358c7175aab9bcd4a3e7ac974 (patch) | |
| tree | 5995f80152d5f98e4bc249f4ce0f191dd35d5d94 /lldb | |
| parent | b894ecf9033e2d205fd8c5b82fe7b7df7f8dca7c (diff) | |
| download | bcm5719-llvm-79d8105fc80b866358c7175aab9bcd4a3e7ac974.tar.gz bcm5719-llvm-79d8105fc80b866358c7175aab9bcd4a3e7ac974.zip | |
"help finish" tells you it is an alias. "help fin" doesn't.
They both run the same command, and people get used to typing the shortest
string they can, so we should support alias info on shortened strings as well.
<rdar://problem/46859207>
llvm-svn: 349874
Diffstat (limited to 'lldb')
| -rw-r--r-- | lldb/packages/Python/lldbsuite/test/help/TestHelp.py | 11 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectHelp.cpp | 9 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/help/TestHelp.py b/lldb/packages/Python/lldbsuite/test/help/TestHelp.py index 2b89b49a622..7d66b08b86a 100644 --- a/lldb/packages/Python/lldbsuite/test/help/TestHelp.py +++ b/lldb/packages/Python/lldbsuite/test/help/TestHelp.py @@ -231,6 +231,17 @@ class HelpCommandTestCase(TestBase): self.expect("help averyfriendlyalias", matching=True, substrs=['I am a very friendly alias']) @no_debug_info_test + def test_alias_prints_origin(self): + """Test that 'help <unique_match_to_alias>' prints the alias origin.""" + def cleanup(): + self.runCmd('command unalias alongaliasname', check=False) + + self.addTearDownHook(cleanup) + self.runCmd('command alias alongaliasname help') + self.expect("help alongaliasna", matching=True, + substrs=["'alongaliasna' is an abbreviation for 'help'"]) + + @no_debug_info_test def test_help_format_output(self): """Test that help output reaches TerminalWidth.""" self.runCmd( diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 9f75e6255d6..1f1d63d7290 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -167,10 +167,13 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { } sub_cmd_obj->GenerateHelpText(result); - - if (m_interpreter.AliasExists(command_name)) { + std::string alias_full_name; + // Don't use AliasExists here, that only checks exact name matches. If + // the user typed a shorter unique alias name, we should still tell them + // it was an alias. + if (m_interpreter.GetAliasFullName(command_name, alias_full_name)) { StreamString sstr; - m_interpreter.GetAlias(command_name)->GetAliasExpansion(sstr); + m_interpreter.GetAlias(alias_full_name)->GetAliasExpansion(sstr); result.GetOutputStream().Printf("\n'%s' is an abbreviation for %s\n", command[0].c_str(), sstr.GetData()); } |

