summaryrefslogtreecommitdiffstats
path: root/cmd-new-window.c
diff options
context:
space:
mode:
authornicm <nicm>2014-04-17 13:02:59 +0000
committernicm <nicm>2014-04-17 13:02:59 +0000
commit3e27be353d045ea231259e96892ad8be273bf9ae (patch)
tree23f19f033bbc33a725465e7d8ef6e3a7987e9d7d /cmd-new-window.c
parentc3b2e5eed3b3ad4fd33cf011c5f4de6d25c602c0 (diff)
Set PATH explicitly, either from client or session
environment. Previously it came from the session environment. From J Raynor.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r--cmd-new-window.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c
index e205e6bc..dc1bbfaa 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -49,10 +49,11 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
struct session *s;
struct winlink *wl;
struct client *c;
- const char *cmd, *template;
+ const char *cmd, *path, *template;
char *cause, *cp;
int idx, last, detached, cwd, fd = -1;
struct format_tree *ft;
+ struct environ_entry *envent;
if (args_has(args, 'a')) {
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
@@ -77,7 +78,8 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
server_unlink_window(s, wl);
}
} else {
- if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &s)) == -2)
+ idx = cmd_find_index(cmdq, args_get(args, 't'), &s);
+ if (idx == -2)
return (CMD_RETURN_ERROR);
}
detached = args_has(args, 'd');
@@ -87,6 +89,14 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
else
cmd = args->argv[0];
+ path = NULL;
+ if (cmdq->client != NULL && cmdq->client->session == NULL)
+ envent = environ_find(&cmdq->client->environ, "PATH");
+ else
+ envent = environ_find(&s->environ, "PATH");
+ if (envent != NULL)
+ path = envent->value;
+
if (args_has(args, 'c')) {
ft = format_create();
if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
@@ -135,7 +145,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
if (idx == -1)
idx = -1 - options_get_number(&s->options, "base-index");
- wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);
+ wl = session_new(s, args_get(args, 'n'), cmd, path, cwd, idx, &cause);
if (wl == NULL) {
cmdq_error(cmdq, "create window failed: %s", cause);
free(cause);