diff options
author | nicm <nicm> | 2014-04-17 13:02:59 +0000 |
---|---|---|
committer | nicm <nicm> | 2014-04-17 13:02:59 +0000 |
commit | 3e27be353d045ea231259e96892ad8be273bf9ae (patch) | |
tree | 23f19f033bbc33a725465e7d8ef6e3a7987e9d7d /cmd-new-session.c | |
parent | c3b2e5eed3b3ad4fd33cf011c5f4de6d25c602c0 (diff) | |
download | rtmux-3e27be353d045ea231259e96892ad8be273bf9ae.tar.gz rtmux-3e27be353d045ea231259e96892ad8be273bf9ae.tar.bz2 rtmux-3e27be353d045ea231259e96892ad8be273bf9ae.zip |
Set PATH explicitly, either from client or session
environment. Previously it came from the session environment. From J
Raynor.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r-- | cmd-new-session.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c index 22c3c5d6..3f8ebe69 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -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); |