From 6b2129696fbefe44d0adce1f2a11b4ae477cd07e Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 4 Jun 2015 23:27:51 +0000 Subject: Move the nested check from client to server and compare the client tty name to all the pane pty names instead of comparing socket paths. This means that "new -d" will work without unsetting $TMUX. --- cmd-new-session.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'cmd-new-session.c') diff --git a/cmd-new-session.c b/cmd-new-session.c index 9c767489..0fb849e2 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -41,7 +41,7 @@ const struct cmd_entry cmd_new_session_entry = { "[-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, + CMD_STARTSERVER, cmd_new_session_exec }; @@ -145,15 +145,20 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) } /* - * Save the termios settings, part of which is used for new windows in - * this session. + * If this is a new client, check for nesting and save the termios + * settings (part of which is used for new windows in this session). * - * This is read again with tcgetattr() rather than using tty.tio as if - * detached, tty_open won't be called. Because of this, it must be done - * before opening the terminal as that calls tcsetattr() to prepare for - * tmux taking over. + * tcgetattr() is used rather than using tty.tio since if the client is + * detached, tty_open won't be called. It must be done before opening + * the terminal as that calls tcsetattr() to prepare for tmux taking + * over. */ if (!detached && !already_attached && c->tty.fd != -1) { + if (server_client_check_nested(cmdq->client)) { + cmdq_error(cmdq, "sessions should be nested with care, " + "unset $TMUX to force"); + return (CMD_RETURN_ERROR); + } if (tcgetattr(c->tty.fd, &tio) != 0) fatal("tcgetattr failed"); tiop = &tio; -- cgit From c4e811e51936edab66803a7b9e099ac135e6e19b Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 7 Jun 2015 21:39:39 +0000 Subject: Add -E flag when attaching or switching client to bypass update-environment, from Steven Lu. --- cmd-new-session.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cmd-new-session.c') diff --git a/cmd-new-session.c b/cmd-new-session.c index 0fb849e2..1533e5f0 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -37,8 +37,8 @@ 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, - "[-AdDP] [-c start-directory] [-F format] [-n window-name] " + "Ac:dDEF:n:Ps:t:x:y:", 0, -1, + "[-AdDEP] [-c start-directory] [-F format] [-n window-name] " "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] " "[-y height] [command]", CMD_STARTSERVER, @@ -91,7 +91,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) if (session_find(newname) != NULL) { if (args_has(args, 'A')) { return (cmd_attach_session(cmdq, newname, - args_has(args, 'D'), 0, NULL)); + args_has(args, 'D'), 0, NULL, + args_has(args, 'E'))); } cmdq_error(cmdq, "duplicate session: %s", newname); return (CMD_RETURN_ERROR); @@ -230,9 +231,11 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) /* Construct the environment. */ environ_init(&env); - update = options_get_string(&global_s_options, "update-environment"); - if (c != NULL) + if (c != NULL && !args_has(args, 'E')) { + update = options_get_string(&global_s_options, + "update-environment"); environ_update(update, &c->environ, &env); + } /* Create the new session. */ idx = -1 - options_get_number(&global_s_options, "base-index"); -- cgit