summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd.c b/src/cmd.c
index 4c9d4ca..f0ad6e9 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -73,8 +73,8 @@ static int ctx_alloc(struct cmd_ctx **ctxp, const struct cmd *cmd)
}
-static struct cmds *cmds_find(const struct commands *commands,
- const struct cmd *cmdv)
+struct cmds *cmds_find(const struct commands *commands,
+ const struct cmd *cmdv)
{
struct le *le;
@@ -396,6 +396,17 @@ int cmd_register(struct commands *commands,
for (i=0; i<cmdc; i++) {
const struct cmd *cmd = &cmdv[i];
+ if (cmd->key) {
+ const struct cmd *x = cmd_find_by_key(commands,
+ cmd->key);
+ if (x) {
+ warning("short command '%c' already"
+ " registered as \"%s\"\n",
+ x->key, x->desc);
+ return EALREADY;
+ }
+ }
+
if (cmd->key == LONG_PREFIX) {
warning("cmd: cannot register command with"
" short key '%c'\n", cmd->key);