CmdExec: Prevent user from executing an empty command

Closes #2503.
This commit is contained in:
Tomas Babej 2021-06-10 20:29:25 -04:00
parent 496773b386
commit 5e5a48606f

View file

@ -49,7 +49,15 @@ CmdExec::CmdExec ()
////////////////////////////////////////////////////////////////////////////////
int CmdExec::execute (std::string&)
{
return system (join (" ", Context::getContext ().cli2.getWords ()).c_str ());
std::string command = join (" ", Context::getContext ().cli2.getWords ());
if (command.empty())
{
Context::getContext ().error ("Cannot execute an empty command.");
return 1;
}
else
return system (command.c_str ());
}
////////////////////////////////////////////////////////////////////////////////