mirror of
https://github.com/tmux/tmux.git
synced 2025-01-15 05:09:04 +00:00
Warn on ambiguous commands.
This commit is contained in:
parent
7258275605
commit
91eb9206d0
1
TODO
1
TODO
@ -43,6 +43,5 @@
|
|||||||
close window
|
close window
|
||||||
kill session
|
kill session
|
||||||
- fix resize (width problems with multiple clients?)
|
- fix resize (width problems with multiple clients?)
|
||||||
- deal properly with ambiguous ops... list-sessions & list-windows
|
|
||||||
- handle tmux in tmux (check $TMUX and abort)
|
- handle tmux in tmux (check $TMUX and abort)
|
||||||
- check for some reqd terminfo caps on startup
|
- check for some reqd terminfo caps on startup
|
||||||
|
19
tmux.c
19
tmux.c
@ -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>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -49,7 +49,7 @@ struct op op_table[] = {
|
|||||||
{ "list-sessions", "ls", op_list_sessions },
|
{ "list-sessions", "ls", op_list_sessions },
|
||||||
{ "list-windows", "lsw", op_list_windows },
|
{ "list-windows", "lsw", op_list_windows },
|
||||||
{ "new-session", "new", op_new/*_session*/ },
|
{ "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])
|
#define NOP (sizeof op_table / sizeof op_table[0])
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ sigreset(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct op *op;
|
struct op *op, *found;
|
||||||
char *path;
|
char *path;
|
||||||
int opt;
|
int opt;
|
||||||
u_int i;
|
u_int i;
|
||||||
@ -186,12 +186,21 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
status_lines = 1;
|
status_lines = 1;
|
||||||
|
|
||||||
|
found = NULL;
|
||||||
for (i = 0; i < NOP; i++) {
|
for (i = 0; i < NOP; i++) {
|
||||||
op = op_table + i;
|
op = op_table + i;
|
||||||
if (strncmp(argv[0], op->cmd, strlen(argv[0])) == 0 ||
|
if (op->alias != NULL && strcmp(argv[0], op->alias) == 0)
|
||||||
(op->alias != NULL && strcmp(argv[0], op->alias) == 0))
|
|
||||||
exit(op->fn(path, argc, argv));
|
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));
|
exit(usage(NULL));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user