Add -E flag when attaching or switching client to bypass

update-environment, from Steven Lu.
This commit is contained in:
nicm
2015-06-07 21:39:39 +00:00
parent ed6c036ee3
commit c4e811e519
5 changed files with 61 additions and 35 deletions

View File

@ -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");