diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-07 21:23:23 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-07 21:23:23 +0000 |
commit | 10428bd9b260b09ba9f96d016e4664ddbb6dc7c7 (patch) | |
tree | 831676e526bfab8fff83a8208b8dcb90a790da9f /usr.bin/tmux/cmd.c | |
parent | b2315bab9a228dd7d33d770574f02f462043262f (diff) |
Don't let ambiguous commands override an exact alias match: eg if commands
"abc-1", "abc-2", "abc-3" exist and "abc-3" has the alias "abc", "tmux abc"
should execute abc-3, not complain about the command being ambiguous.
Not a problem at the moment but will be soon.
Diffstat (limited to 'usr.bin/tmux/cmd.c')
-rw-r--r-- | usr.bin/tmux/cmd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index e652abd4afb..26c6770d38f 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.2 2009/06/04 23:34:32 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.3 2009/07/07 21:23:22 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); |