=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-new-session.c,v retrieving revision 1.130 retrieving revision 1.131 diff -c -r1.130 -r1.131 *** src/usr.bin/tmux/cmd-new-session.c 2020/04/13 20:51:57 1.130 --- src/usr.bin/tmux/cmd-new-session.c 2020/05/16 14:49:50 1.131 *************** *** 1,4 **** ! /* $OpenBSD: cmd-new-session.c,v 1.130 2020/04/13 20:51:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-new-session.c,v 1.131 2020/05/16 14:49:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 70,82 **** struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct client *c = cmdq_get_client(item); ! struct session *s, *as, *groupwith; struct environ *env; struct options *oo; struct termios tio, *tiop; ! struct session_group *sg; ! const char *errstr, *template, *group, *prefix, *tmp; char *cause, *cwd = NULL, *cp, *newname = NULL; int detached, already_attached, is_control = 0; u_int sx, sy, dsx, dsy; struct spawn_context sc; --- 70,83 ---- struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct client *c = cmdq_get_client(item); ! struct session *s, *as, *groupwith = NULL; struct environ *env; struct options *oo; struct termios tio, *tiop; ! struct session_group *sg = NULL; ! const char *errstr, *template, *group, *tmp; char *cause, *cwd = NULL, *cp, *newname = NULL; + char *name, *prefix = NULL; int detached, already_attached, is_control = 0; u_int sx, sy, dsx, dsy; struct spawn_context sc; *************** *** 98,108 **** tmp = args_get(args, 's'); if (tmp != NULL) { ! newname = format_single(item, tmp, c, NULL, NULL, NULL); ! if (!session_check_name(newname)) { ! cmdq_error(item, "bad session name: %s", newname); ! goto fail; ! } } if (args_has(args, 'A')) { if (newname != NULL) --- 99,107 ---- tmp = args_get(args, 's'); if (tmp != NULL) { ! name = format_single(item, tmp, c, NULL, NULL, NULL); ! newname = session_check_name(name); ! free(name); } if (args_has(args, 'A')) { if (newname != NULL) *************** *** 126,149 **** group = args_get(args, 't'); if (group != NULL) { groupwith = target->s; ! if (groupwith == NULL) { ! if (!session_check_name(group)) { ! cmdq_error(item, "bad group name: %s", group); ! goto fail; ! } sg = session_group_find(group); ! } else sg = session_group_contains(groupwith); if (sg != NULL) ! prefix = sg->name; else if (groupwith != NULL) ! prefix = groupwith->name; else ! prefix = group; ! } else { ! groupwith = NULL; ! sg = NULL; ! prefix = NULL; } /* Set -d if no client. */ --- 125,140 ---- group = args_get(args, 't'); if (group != NULL) { groupwith = target->s; ! if (groupwith == NULL) sg = session_group_find(group); ! else sg = session_group_contains(groupwith); if (sg != NULL) ! prefix = xstrdup(sg->name); else if (groupwith != NULL) ! prefix = xstrdup(groupwith->name); else ! prefix = session_check_name(group); } /* Set -d if no client. */ *************** *** 353,362 **** --- 344,355 ---- free(cwd); free(newname); + free(prefix); return (CMD_RETURN_NORMAL); fail: free(cwd); free(newname); + free(prefix); return (CMD_RETURN_ERROR); }