summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-attach-session.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-06-07 21:39:39 +0000
committernicm <nicm@openbsd.org>2015-06-07 21:39:39 +0000
commitf8e30f69c6b1033a47573127978509bfdc8946c8 (patch)
tree95c7d1a8a6951664107932ef718bbdc0a14a9c92 /usr.bin/tmux/cmd-attach-session.c
parentHBG is no more so no need to mention it in the man pages. (diff)
downloadwireguard-openbsd-f8e30f69c6b1033a47573127978509bfdc8946c8.tar.xz
wireguard-openbsd-f8e30f69c6b1033a47573127978509bfdc8946c8.zip
Add -E flag when attaching or switching client to bypass
update-environment, from Steven Lu.
Diffstat (limited to 'usr.bin/tmux/cmd-attach-session.c')
-rw-r--r--usr.bin/tmux/cmd-attach-session.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c
index 7d7740317a2..b53bb98827e 100644
--- a/usr.bin/tmux/cmd-attach-session.c
+++ b/usr.bin/tmux/cmd-attach-session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-attach-session.c,v 1.35 2015/06/04 23:27:51 nicm Exp $ */
+/* $OpenBSD: cmd-attach-session.c,v 1.36 2015/06/07 21:39:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,18 +34,18 @@ enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach",
- "c:drt:", 0, 0,
- "[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
+ "c:dErt:", 0, 0,
+ "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
CMD_STARTSERVER,
cmd_attach_session_exec
};
enum cmd_retval
cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
- const char *cflag)
+ const char *cflag, int Eflag)
{
struct session *s;
- struct client *c;
+ struct client *c = cmdq->client, *c_loop;
struct winlink *wl = NULL;
struct window *w = NULL;
struct window_pane *wp = NULL;
@@ -79,9 +79,9 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
wl = winlink_find_by_window(&s->windows, w);
}
- if (cmdq->client == NULL)
+ if (c == NULL)
return (CMD_RETURN_NORMAL);
- if (server_client_check_nested(cmdq->client)) {
+ if (server_client_check_nested(c)) {
cmdq_error(cmdq, "sessions should be nested with care, "
"unset $TMUX to force");
return (CMD_RETURN_ERROR);
@@ -93,18 +93,18 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
session_set_current(s, wl);
}
- if (cmdq->client->session != NULL) {
+ if (c->session != NULL) {
if (dflag) {
/*
* Can't use server_write_session in case attaching to
* the same session as currently attached to.
*/
- TAILQ_FOREACH(c, &clients, entry) {
- if (c->session != s || c == cmdq->client)
+ TAILQ_FOREACH(c_loop, &clients, entry) {
+ if (c_loop->session != s || c == c)
continue;
server_write_client(c, MSG_DETACH,
- c->session->name,
- strlen(c->session->name) + 1);
+ c_loop->session->name,
+ strlen(c_loop->session->name) + 1);
}
}
@@ -126,13 +126,13 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
s->cwd = fd;
}
- cmdq->client->session = s;
- notify_attached_session_changed(cmdq->client);
+ c->session = s;
+ notify_attached_session_changed(c);
session_update_activity(s);
- server_redraw_client(cmdq->client);
+ server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
} else {
- if (server_client_open(cmdq->client, &cause) != 0) {
+ if (server_client_open(c, &cause) != 0) {
cmdq_error(cmdq, "open terminal failed: %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
@@ -157,23 +157,26 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
}
if (rflag)
- cmdq->client->flags |= CLIENT_READONLY;
+ c->flags |= CLIENT_READONLY;
if (dflag) {
server_write_session(s, MSG_DETACH, s->name,
strlen(s->name) + 1);
}
- update = options_get_string(&s->options, "update-environment");
- environ_update(update, &cmdq->client->environ, &s->environ);
+ if (!Eflag) {
+ update = options_get_string(&s->options,
+ "update-environment");
+ environ_update(update, &c->environ, &s->environ);
+ }
- cmdq->client->session = s;
- notify_attached_session_changed(cmdq->client);
+ c->session = s;
+ notify_attached_session_changed(c);
session_update_activity(s);
- server_redraw_client(cmdq->client);
+ server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
- server_write_ready(cmdq->client);
+ server_write_ready(c);
cmdq->client_exit = 0;
}
recalculate_sizes();
@@ -188,5 +191,6 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq)
struct args *args = self->args;
return (cmd_attach_session(cmdq, args_get(args, 't'),
- args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c')));
+ args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'),
+ args_has(args, 'E')));
}