Prevent whitespaces in command names

Fixes #1843
This commit is contained in:
Maxime Coste 2018-02-11 20:35:21 +11:00
parent 01259bf22c
commit f3c19ba7fa

View File

@ -842,6 +842,9 @@ void define_command(const ParametersParser& parser, Context& context, const Shel
const String& cmd_name = parser[0];
auto& cm = CommandManager::instance();
if (contains_that(cmd_name, is_blank))
throw runtime_error(format("invalid command name: '{}'", cmd_name));
if (cm.command_defined(cmd_name) and not parser.get_switch("allow-override"))
throw runtime_error(format("command '{}' already defined", cmd_name));