aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd.c b/cmd.c
index 68dd06a3..af520f0f 100644
--- a/cmd.c
+++ b/cmd.c
@@ -105,7 +105,7 @@ cmd_parse(int argc, char **argv, char **cause)
const struct cmd_entry **entryp, *entry;
struct cmd *cmd;
char s[BUFSIZ];
- int opt;
+ int opt, ambiguous = 0;
*cause = NULL;
if (argc == 0) {
@@ -117,6 +117,7 @@ cmd_parse(int argc, char **argv, char **cause)
for (entryp = cmd_table; *entryp != NULL; entryp++) {
if ((*entryp)->alias != NULL &&
strcmp((*entryp)->alias, argv[0]) == 0) {
+ ambiguous = 0;
entry = *entryp;
break;
}
@@ -124,13 +125,15 @@ cmd_parse(int argc, char **argv, char **cause)
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
continue;
if (entry != NULL)
- goto ambiguous;
+ ambiguous = 1;
entry = *entryp;
/* Bail now if an exact match. */
if (strcmp(entry->name, argv[0]) == 0)
break;
}
+ if (ambiguous)
+ goto ambiguous;
if (entry == NULL) {
xasprintf(cause, "unknown command: %s", argv[0]);
return (NULL);