mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-17 09:01:34 +02:00
If multiple arguments are given to new-session, new-window,
split-window, respawn-window or respawn-pane, pass them directly to execvp() to help avoid quoting problems. One argument still goes to "sh -c" like before. Requested by many over the years. Patch from J Raynor.
This commit is contained in:
@ -35,10 +35,10 @@ enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
|
||||
|
||||
const struct cmd_entry cmd_new_session_entry = {
|
||||
"new-session", "new",
|
||||
"Ac:dDF:n:Ps:t:x:y:", 0, 1,
|
||||
"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]",
|
||||
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
|
||||
"[-y height] [command]",
|
||||
CMD_STARTSERVER|CMD_CANTNEST,
|
||||
NULL,
|
||||
cmd_new_session_exec
|
||||
@ -55,8 +55,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
struct termios tio, *tiop;
|
||||
const char *newname, *target, *update, *errstr, *template;
|
||||
const char *path;
|
||||
char *cmd, *cause, *cp;
|
||||
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,12 +184,21 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
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
|
||||
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,8 +216,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
|
||||
/* 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);
|
||||
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,7 +226,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
environ_free(&env);
|
||||
|
||||
/* Set the initial window name if one given. */
|
||||
if (cmd != NULL && args_has(args, 'n')) {
|
||||
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);
|
||||
|
Reference in New Issue
Block a user