summaryrefslogtreecommitdiffstats
path: root/cmd-if-shell.c
diff options
context:
space:
mode:
authornicm <nicm>2015-04-24 22:19:36 +0000
committernicm <nicm>2015-04-24 22:19:36 +0000
commit583b4ab72b7bf66fda8ab63a08fe435483de5e5a (patch)
tree7620822095c73c5d78942cdfa7005d6a6f50019d /cmd-if-shell.c
parent5a2d0533a84a13613fb356b66ed8ada2a65f6edf (diff)
Set working directory for run-shell and if-shell.
Diffstat (limited to 'cmd-if-shell.c')
-rw-r--r--cmd-if-shell.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index cdd2135c..a307bd2f 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -66,16 +66,24 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
struct winlink *wl = NULL;
struct window_pane *wp = NULL;
struct format_tree *ft;
+ int cwd;
- if (args_has(args, 't'))
+ if (args_has(args, 't')) {
wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
- else {
+ cwd = wp->cwd;
+ } else {
c = cmd_find_client(cmdq, NULL, 1);
if (c != NULL && c->session != NULL) {
s = c->session;
wl = s->curw;
wp = wl->window->active;
}
+ if (cmdq->client != NULL && cmdq->client->session == NULL)
+ cwd = cmdq->client->cwd;
+ else if (s != NULL)
+ cwd = s->cwd;
+ else
+ cwd = -1;
}
ft = format_create();
@@ -118,7 +126,8 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
cmdq->references++;
cdata->references = 1;
- job_run(shellcmd, s, cmd_if_shell_callback, cmd_if_shell_free, cdata);
+ job_run(shellcmd, s, cwd, cmd_if_shell_callback, cmd_if_shell_free,
+ cdata);
free(shellcmd);
if (cdata->bflag)