[PATCH 3/4] vsh: Extend checks for aliased commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <mprivozn@xxxxxxxxxx>
---
 tools/vsh.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/vsh.c b/tools/vsh.c
index cf24586b25..3d5fef84f0 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;
     }
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux