summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-new-session.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-04-17 13:02:59 +0000
committernicm <nicm@openbsd.org>2014-04-17 13:02:59 +0000
commit1a0db3015ea731ed484e4af0811ff30aef5f77dc (patch)
treed4cc69063d740f9490fc4436cd841487c5c2d569 /usr.bin/tmux/cmd-new-session.c
parentWrap some long lines. (diff)
downloadwireguard-openbsd-1a0db3015ea731ed484e4af0811ff30aef5f77dc.tar.xz
wireguard-openbsd-1a0db3015ea731ed484e4af0811ff30aef5f77dc.zip
Set PATH explicitly, either from client or session
environment. Previously it came from the session environment. From J Raynor.
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r--usr.bin/tmux/cmd-new-session.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c
index cc39946d0d9..c1b49fe1e9e 100644
--- a/usr.bin/tmux/cmd-new-session.c
+++ b/usr.bin/tmux/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-new-session.c,v 1.58 2014/04/17 11:38:35 nicm Exp $ */
+/* $OpenBSD: cmd-new-session.c,v 1.59 2014/04/17 13:02:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -54,10 +54,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
struct environ env;
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;
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) {
cmdq_error(cmdq, "command or window name given with target");
@@ -188,6 +190,14 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
else
cmd = options_get_string(&global_s_options, "default-command");
+ path = NULL;
+ if (c != NULL && c->session == NULL)
+ envent = environ_find(&c->environ, "PATH");
+ else
+ envent = environ_find(&global_environ, "PATH");
+ if (envent != NULL)
+ path = envent->value;
+
/* Construct the environment. */
environ_init(&env);
update = options_get_string(&global_s_options, "update-environment");
@@ -196,7 +206,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, cwd, &env, tiop, idx, sx, sy, &cause);
+ 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);