From 023d8d38ec7d59bbf635253f10e82e0b62ba59ca Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 13 Jul 2009 17:47:46 +0000 Subject: Tidy up and improve target (-t) argument parsing: - move the code back into cmd.c and merge with the existing functions where possible; - accept "-tttyp0" as well as "-t/dev/ttyp0" for clients; - when looking up session names, try an exact match first, and if that fails look for it as an fnmatch pattern and then as the start of a name - if more that one session matches an error is given; so if there is one session called "mysession", -tmysession, -tmysess, -tmysess* are equivalent but if there is also "mysession2", the last two are errors; - similarly for windows, if the argument is not a valid index or exact window name match, try it against the window names as an fnmatch pattern and a prefix. --- cmd-new-window.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'cmd-new-window.c') diff --git a/cmd-new-window.c b/cmd-new-window.c index 30b84ac3..ee8cd8b7 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -126,18 +126,8 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (data == NULL) return (0); - if (arg_parse_window(data->target, &s, &idx) != 0) { - ctx->error(ctx, "bad window: %s", data->target); + if ((idx = cmd_find_index(ctx, data->target, &s)) == -2) return (-1); - } - if (s == NULL) - s = ctx->cursession; - if (s == NULL) - s = cmd_current_session(ctx); - if (s == NULL) { - ctx->error(ctx, "session not found: %s", data->target); - return (-1); - } wl = NULL; if (idx != -1) -- cgit v1.2.3