From: Michal Privoznik Date: Fri, 17 Sep 2021 07:52:43 +0000 (+0200) Subject: vsh: Extend checks for aliased commands X-Git-Tag: v7.8.0-rc1~139 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1a22b0b1cbe51bc9d923a73f131429357cb0640;p=thirdparty%2Flibvirt.git vsh: Extend checks for aliased commands If a command is an alias, then it can only have .name, .flags and .alias set and .flags should contain just VSH_CMD_FLAG_ALIAS. Check if that's the case in self-test. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/tools/vsh.c b/tools/vsh.c index 9057310077..dd6930730d 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -290,6 +290,26 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; } + if (cmd->handler) { + vshError(ctl, _("command '%s' has handler set"), cmd->name); + return -1; + } + + if (cmd->opts) { + vshError(ctl, _("command '%s' has options set"), cmd->name); + return -1; + } + + if (cmd->info) { + vshError(ctl, _("command '%s' has info set"), cmd->name); + return -1; + } + + if (cmd->flags & ~VSH_CMD_FLAG_ALIAS) { + vshError(ctl, _("command '%s' has multiple flags set"), cmd->name); + return -1; + } + /* we don't need to continue as the real command will be checked separately */ return 0; }