diff options
author | Enrico Granata <egranata@apple.com> | 2016-04-08 17:56:57 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2016-04-08 17:56:57 +0000 |
commit | d72e412f68de36c4da966ef4b0dd53e4017b2475 (patch) | |
tree | 60dbd6d719b4cc9deebe7ccfdd524f41d573b0d2 | |
parent | 648e438a34491df79c82a7cd674f8fab3cf1771a (diff) | |
download | bcm5719-llvm-d72e412f68de36c4da966ef4b0dd53e4017b2475.tar.gz bcm5719-llvm-d72e412f68de36c4da966ef4b0dd53e4017b2475.zip |
Cleanups to command alias to refer to itself as 'command alias' and not allow to make aliases starting with a - as that isn't really supported, and is most often a mistake (trying to pass options)
llvm-svn: 265820
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 62711403a04..5dae9a078cd 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -631,7 +631,7 @@ protected: { if (!raw_command_line || !raw_command_line[0]) { - result.AppendError ("'alias' requires at least two arguments"); + result.AppendError ("'command alias' requires at least two arguments"); return false; } @@ -686,7 +686,7 @@ protected: if (argc < 2) { - result.AppendError ("'alias' requires at least two arguments"); + result.AppendError ("'command alias' requires at least two arguments"); result.SetStatus (eReturnStatusFailed); return false; } @@ -694,6 +694,17 @@ protected: // Get the alias command. const std::string alias_command = args.GetArgumentAtIndex (0); + if (alias_command.size() > 1 && + alias_command[0] == '-') + { + result.AppendError("aliases starting with a dash are not supported"); + if (alias_command == "--help" || alias_command == "--long-help") + { + result.AppendWarning("if trying to pass options to 'command alias' add a -- at the end of the options"); + } + result.SetStatus (eReturnStatusFailed); + return false; + } // Strip the new alias name off 'raw_command_string' (leave it on args, which gets passed to 'Execute', which // does the stripping itself. @@ -724,12 +735,13 @@ protected: // Get CommandObject that is being aliased. The command name is read from the front of raw_command_string. // raw_command_string is returned with the name of the command object stripped off the front. + std::string original_raw_command_string(raw_command_string); CommandObject *cmd_obj = m_interpreter.GetCommandObjectForCommand (raw_command_string); if (!cmd_obj) { - result.AppendErrorWithFormat ("invalid command given to 'alias'. '%s' does not begin with a valid command." - " No alias created.", raw_command_string.c_str()); + result.AppendErrorWithFormat ("invalid command given to 'command alias'. '%s' does not begin with a valid command." + " No alias created.", original_raw_command_string.c_str()); result.SetStatus (eReturnStatusFailed); return false; } @@ -792,7 +804,7 @@ protected: if (argc < 2) { - result.AppendError ("'alias' requires at least two arguments"); + result.AppendError ("'command alias' requires at least two arguments"); result.SetStatus (eReturnStatusFailed); return false; } |