summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authornicm <nicm>2016-01-31 09:52:01 +0000
committernicm <nicm>2016-01-31 09:52:01 +0000
commit225a384dbb5ffe5fc91c59ebcaeda1946b80ca69 (patch)
treebfdfdf6a9cf50d189fb74b926e675df2890f08b6 /cmd-new-session.c
parent427b8204268af5548d09b830e101c59daa095df9 (diff)
Fix new-session with -t after command flags changes, reported by Michael Graczyk.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index b4bb37d5..ecbc5983 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -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);