=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-new-session.c,v retrieving revision 1.59 retrieving revision 1.60 diff -c -r1.59 -r1.60 *** src/usr.bin/tmux/cmd-new-session.c 2014/04/17 13:02:59 1.59 --- src/usr.bin/tmux/cmd-new-session.c 2014/05/13 08:08:32 1.60 *************** *** 1,4 **** ! /* $OpenBSD: cmd-new-session.c,v 1.59 2014/04/17 13:02:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-new-session.c,v 1.60 2014/05/13 08:08:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 35,44 **** const struct cmd_entry cmd_new_session_entry = { "new-session", "new", ! "Ac:dDF:n:Ps:t:x:y:", 0, 1, "[-AdDP] [-c start-directory] [-F format] [-n window-name] " ! "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] [-y height] " ! "[command]", CMD_STARTSERVER|CMD_CANTNEST, NULL, cmd_new_session_exec --- 35,44 ---- const struct cmd_entry cmd_new_session_entry = { "new-session", "new", ! "Ac:dDF:n:Ps:t:x:y:", 0, -1, "[-AdDP] [-c start-directory] [-F format] [-n window-name] " ! "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] " ! "[-y height] [command]", CMD_STARTSERVER|CMD_CANTNEST, NULL, cmd_new_session_exec *************** *** 55,62 **** struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; const char *path; ! char *cmd, *cause, *cp; int detached, already_attached, idx, cwd, fd = -1; u_int sx, sy; struct format_tree *ft; struct environ_entry *envent; --- 55,63 ---- struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; const char *path; ! char **argv, *cmd, *cause, *cp; int detached, already_attached, idx, cwd, fd = -1; + int argc; u_int sx, sy; struct format_tree *ft; struct environ_entry *envent; *************** *** 183,194 **** sy = 1; /* Figure out the command for the new window. */ ! if (target != NULL) ! cmd = NULL; ! else if (args->argc != 0) ! cmd = args->argv[0]; ! else cmd = options_get_string(&global_s_options, "default-command"); path = NULL; if (c != NULL && c->session == NULL) --- 184,204 ---- sy = 1; /* Figure out the command for the new window. */ ! argc = -1; ! argv = NULL; ! if (target == NULL && 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; + argv = &cmd; + } else { + argc = 0; + argv = NULL; + } + } path = NULL; if (c != NULL && c->session == NULL) *************** *** 206,213 **** /* Create the new session. */ idx = -1 - options_get_number(&global_s_options, "base-index"); ! s = session_create(newname, cmd, path, cwd, &env, tiop, idx, sx, sy, ! &cause); if (s == NULL) { cmdq_error(cmdq, "create session failed: %s", cause); free(cause); --- 216,223 ---- /* Create the new session. */ idx = -1 - options_get_number(&global_s_options, "base-index"); ! s = session_create(newname, argc, argv, path, cwd, &env, tiop, idx, sx, ! sy, &cause); if (s == NULL) { cmdq_error(cmdq, "create session failed: %s", cause); free(cause); *************** *** 216,222 **** environ_free(&env); /* Set the initial window name if one given. */ ! if (cmd != NULL && args_has(args, 'n')) { w = s->curw->window; window_set_name(w, args_get(args, 'n')); options_set_number(&w->options, "automatic-rename", 0); --- 226,232 ---- environ_free(&env); /* Set the initial window name if one given. */ ! if (argc >= 0 && args_has(args, 'n')) { w = s->curw->window; window_set_name(w, args_get(args, 'n')); options_set_number(&w->options, "automatic-rename", 0);