=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-new-session.c,v retrieving revision 1.84 retrieving revision 1.85 diff -c -r1.84 -r1.85 *** src/usr.bin/tmux/cmd-new-session.c 2016/01/19 15:59:12 1.84 --- src/usr.bin/tmux/cmd-new-session.c 2016/01/31 09:52:01 1.85 *************** *** 1,4 **** ! /* $OpenBSD: cmd-new-session.c,v 1.84 2016/01/19 15:59:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-new-session.c,v 1.85 2016/01/31 09:52:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 74,80 **** struct environ *env; struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; ! const char *path, *cwd, *to_free; char **argv, *cmd, *cause, *cp; int detached, already_attached, idx, argc; u_int sx, sy; --- 74,80 ---- struct environ *env; struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; ! const char *path, *cwd, *to_free = NULL; char **argv, *cmd, *cause, *cp; int detached, already_attached, idx, argc; u_int sx, sy; *************** *** 118,124 **** } } ! if ((target = args_get(args, 't')) == NULL) groupwith = NULL; /* Set -d if no client. */ --- 118,129 ---- } } ! 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,138 **** 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); --- 137,142 ---- *************** *** 208,214 **** if (!args_has(args, 't') && args->argc != 0) { argc = args->argc; argv = args->argv; ! } else if (target == NULL) { cmd = options_get_string(global_s_options, "default-command"); if (cmd != NULL && *cmd != '\0') { argc = 1; --- 212,218 ---- if (!args_has(args, 't') && args->argc != 0) { argc = args->argc; argv = args->argv; ! } else if (groupwith == NULL) { cmd = options_get_string(global_s_options, "default-command"); if (cmd != NULL && *cmd != '\0') { argc = 1; *************** *** 257,263 **** * 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')) { session_group_add(groupwith, s); session_group_synchronize_to(s); session_select(s, RB_MIN(winlinks, &s->windows)->idx); --- 261,267 ---- * If a target session is given, this is to be part of a session group, * so add it to the group and synchronize. */ ! if (groupwith != NULL) { session_group_add(groupwith, s); session_group_synchronize_to(s); session_select(s, RB_MIN(winlinks, &s->windows)->idx);