@@ -484,29 +484,31 @@ rather than using a positional placeholder:"
484
484
OptionArgVectorSP (new OptionArgVector);
485
485
486
486
const bool include_aliases = true ;
487
- if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (
488
- cmd_obj.GetCommandName (), include_aliases)) {
489
- if (m_interpreter.AliasExists (alias_command) ||
490
- m_interpreter.UserCommandExists (alias_command)) {
491
- result.AppendWarningWithFormat (
492
- " Overwriting existing definition for '%s'.\n " ,
493
- alias_command.str ().c_str ());
494
- }
495
- if (CommandAlias *alias = m_interpreter.AddAlias (
496
- alias_command, cmd_obj_sp, raw_command_string)) {
497
- if (m_command_options.m_help .OptionWasSet ())
498
- alias->SetHelp (m_command_options.m_help .GetCurrentValue ());
499
- if (m_command_options.m_long_help .OptionWasSet ())
500
- alias->SetHelpLong (m_command_options.m_long_help .GetCurrentValue ());
501
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
502
- } else {
503
- result.AppendError (" Unable to create requested alias.\n " );
504
- }
487
+ // Look up the command using command's name first. This is to resolve
488
+ // aliases when you are making nested aliases. But if you don't find
489
+ // it that way, then it wasn't an alias and we can just use the object
490
+ // we were passed in.
491
+ CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (
492
+ cmd_obj.GetCommandName (), include_aliases);
493
+ if (!cmd_obj_sp)
494
+ cmd_obj_sp = cmd_obj.shared_from_this ();
505
495
496
+ if (m_interpreter.AliasExists (alias_command) ||
497
+ m_interpreter.UserCommandExists (alias_command)) {
498
+ result.AppendWarningWithFormat (
499
+ " Overwriting existing definition for '%s'.\n " ,
500
+ alias_command.str ().c_str ());
501
+ }
502
+ if (CommandAlias *alias = m_interpreter.AddAlias (
503
+ alias_command, cmd_obj_sp, raw_command_string)) {
504
+ if (m_command_options.m_help .OptionWasSet ())
505
+ alias->SetHelp (m_command_options.m_help .GetCurrentValue ());
506
+ if (m_command_options.m_long_help .OptionWasSet ())
507
+ alias->SetHelpLong (m_command_options.m_long_help .GetCurrentValue ());
508
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
506
509
} else {
507
510
result.AppendError (" Unable to create requested alias.\n " );
508
511
}
509
-
510
512
return result.Succeeded ();
511
513
}
512
514
0 commit comments