Skip to content

Commit

Permalink
Issue #1693: tidying: reduce the scope of a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Feb 14, 2025
1 parent 9ed2a7a commit dd9b198
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Kernel/System/Console/InterfaceConsole.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,38 @@ execute a command. Returns the shell status code to be used by exit().
sub Run {
my ( $Self, @CommandlineArguments ) = @_;

my $CommandName;

# Catch bash completion calls
if ( $ENV{COMP_LINE} ) {
$CommandName = 'Kernel::System::Console::Command::Internal::BashCompletion';
my $CommandName = 'Kernel::System::Console::Command::Internal::BashCompletion';

return $Kernel::OM->Get($CommandName)->Execute(@CommandlineArguments);
}

# If we don't have any arguments OR the first argument is an option and not a command name,
# show the overview screen instead.
if ( !@CommandlineArguments || substr( $CommandlineArguments[0], 0, 2 ) eq '--' ) {
$CommandName = 'Kernel::System::Console::Command::List';
my $CommandName = 'Kernel::System::Console::Command::List';

return $Kernel::OM->Get($CommandName)->Execute(@CommandlineArguments);
}

# Ok, let's try to find the command.
$CommandName = 'Kernel::System::Console::Command::' . $CommandlineArguments[0];
my $CommandName = 'Kernel::System::Console::Command::' . $CommandlineArguments[0];

if ( $Kernel::OM->Get('Kernel::System::Main')->Require( $CommandName, Silent => 1 ) ) {

# Regular case: everything was ok, execute command.
# Remove first parameter (command itself) to not confuse further parsing
shift @CommandlineArguments;

return $Kernel::OM->Get($CommandName)->Execute(@CommandlineArguments);
}

# If the command cannot be found/loaded, also show the overview screen.
my $CommandObject = $Kernel::OM->Get('Kernel::System::Console::Command::List');
$CommandObject->PrintError("Could not find $CommandName.\n\n");
$CommandObject->Execute();

return 127; # EXIT_CODE_COMMAND_NOT_FOUND, see http://www.tldp.org/LDP/abs/html/exitcodes.html
}

Expand Down

0 comments on commit dd9b198

Please sign in to comment.