summaryrefslogtreecommitdiffstats
path: root/cmd-respawn-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-respawn-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-respawn-window.c')
-rw-r--r--cmd-respawn-window.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c
index b681f2f4..9dc3f07f 100644
--- a/cmd-respawn-window.c
+++ b/cmd-respawn-window.c
@@ -47,8 +47,9 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
struct window_pane *wp;
struct session *s;
struct environ env;
- const char *cmd;
+ const char *cmd, *path;
char *cause;
+ struct environ_entry *envent;
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
return (CMD_RETURN_ERROR);
@@ -79,7 +80,17 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
cmd = args->argv[0];
else
cmd = NULL;
- if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 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 (window_pane_spawn(wp, cmd, path, NULL, -1, &env, s->tio,
+ &cause) != 0) {
cmdq_error(cmdq, "respawn window failed: %s", cause);
free(cause);
environ_free(&env);