diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-01-31 09:52:02 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-01-31 09:52:02 +0000 |
commit | bc1ca484e602f12f377f2e03c1a6c80923f46000 (patch) | |
tree | aa6b5720f82709093b6e128b0cd52c5f4c446e0a /usr.bin/tmux/cmd-new-session.c | |
parent | 3e51587bbb2e72697e5ae443169ac0c2998955a8 (diff) |
Fix new-session with -t after command flags changes, reported by Michael Graczyk.
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 3f99c725709..a6a4fa78eb0 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.84 2016/01/19 15:59:12 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.85 2016/01/31 09:52:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -74,7 +74,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) struct environ *env; struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; - const char *path, *cwd, *to_free; + const char *path, *cwd, *to_free = NULL; char **argv, *cmd, *cause, *cp; int detached, already_attached, idx, argc; u_int sx, sy; @@ -118,7 +118,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) } } - if ((target = args_get(args, 't')) == NULL) + if ((target = args_get(args, 't')) != NULL) { + if (groupwith == NULL) { + cmdq_error(cmdq, "no such session: %s", target); + goto error; + } + } else groupwith = NULL; /* Set -d if no client. */ @@ -132,7 +137,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) already_attached = 1; /* Get the new session working directory. */ - to_free = NULL; if (args_has(args, 'c')) { ft = format_create(cmdq, 0); format_defaults(ft, c, NULL, NULL, NULL); @@ -208,7 +212,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) if (!args_has(args, 't') && args->argc != 0) { argc = args->argc; argv = args->argv; - } else if (target == NULL) { + } else if (groupwith == NULL) { cmd = options_get_string(global_s_options, "default-command"); if (cmd != NULL && *cmd != '\0') { argc = 1; @@ -257,7 +261,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) * If a target session is given, this is to be part of a session group, * so add it to the group and synchronize. */ - if (args_has(args, 't')) { + if (groupwith != NULL) { session_group_add(groupwith, s); session_group_synchronize_to(s); session_select(s, RB_MIN(winlinks, &s->windows)->idx); |