Warn on ambiguous commands.

pull/1/head
Nicholas Marriott 2007-10-02 17:35:00 +00:00
parent 7258275605
commit 91eb9206d0
2 changed files with 15 additions and 7 deletions

1
TODO
View File

@ -43,6 +43,5 @@
close window
kill session
- fix resize (width problems with multiple clients?)
- deal properly with ambiguous ops... list-sessions & list-windows
- handle tmux in tmux (check $TMUX and abort)
- check for some reqd terminfo caps on startup

21
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.18 2007-10-01 14:53:29 nicm Exp $ */
/* $Id: tmux.c,v 1.19 2007-10-02 17:35:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -49,7 +49,7 @@ struct op op_table[] = {
{ "list-sessions", "ls", op_list_sessions },
{ "list-windows", "lsw", op_list_windows },
{ "new-session", "new", op_new/*_session*/ },
{ "rename-window", NULL, op_rename },
{ "rename-window", "renw", op_rename },
};
#define NOP (sizeof op_table / sizeof op_table[0])
@ -158,7 +158,7 @@ sigreset(void)
int
main(int argc, char **argv)
{
struct op *op;
struct op *op, *found;
char *path;
int opt;
u_int i;
@ -185,13 +185,22 @@ main(int argc, char **argv)
log_open(stderr, LOG_USER, debug_level);
status_lines = 1;
found = NULL;
for (i = 0; i < NOP; i++) {
op = op_table + i;
if (strncmp(argv[0], op->cmd, strlen(argv[0])) == 0 ||
(op->alias != NULL && strcmp(argv[0], op->alias) == 0))
if (op->alias != NULL && strcmp(argv[0], op->alias) == 0)
exit(op->fn(path, argc, argv));
if (strncmp(argv[0], op->cmd, strlen(argv[0])) == 0) {
if (found != NULL) {
log_warnx("ambiguous command: %s", argv[0]);
exit(1);
}
found = op;
}
}
if (found != NULL)
exit(found->fn(path, argc, argv));
exit(usage(NULL));
}