Set working directory for run-shell and if-shell.

This commit is contained in:
nicm
2015-04-24 22:19:36 +00:00
parent 5a2d0533a8
commit 583b4ab72b
6 changed files with 31 additions and 10 deletions

View File

@ -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)