diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2013-03-25 11:43:01 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2013-03-25 11:43:01 +0000 |
commit | d28a39d01de47786a703e630a4f8930485cba7a1 (patch) | |
tree | ca4150390534197c5e74ce88bb9824be1627d014 /cmd-if-shell.c | |
parent | 270d90ce1e302e7d015abb30342cca0a6ecff048 (diff) | |
download | rtmux-d28a39d01de47786a703e630a4f8930485cba7a1.tar.gz rtmux-d28a39d01de47786a703e630a4f8930485cba7a1.tar.bz2 rtmux-d28a39d01de47786a703e630a4f8930485cba7a1.zip |
Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.
Diffstat (limited to 'cmd-if-shell.c')
-rw-r--r-- | cmd-if-shell.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/cmd-if-shell.c b/cmd-if-shell.c index e2a45972..a3ca6555 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -59,19 +59,21 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq) struct args *args = self->args; struct cmd_if_shell_data *cdata; char *shellcmd; - struct session *s; - struct winlink *wl; - struct window_pane *wp; + struct session *s = NULL; + struct winlink *wl = NULL; + struct window_pane *wp = NULL; struct format_tree *ft; - wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp); - if (wl == NULL) - return (CMD_RETURN_ERROR); + if (args_has(args, 't')) + wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp); ft = format_create(); - format_session(ft, s); - format_winlink(ft, s, wl); - format_window_pane(ft, wp); + if (s != NULL) + format_session(ft, s); + if (s != NULL && wl != NULL) + format_winlink(ft, s, wl); + if (wp != NULL) + format_window_pane(ft, wp); shellcmd = format_expand(ft, args->argv[0]); format_free(ft); @@ -87,7 +89,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq) cdata->cmdq = cmdq; cmdq->references++; - job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata); + job_run(shellcmd, s, cmd_if_shell_callback, cmd_if_shell_free, cdata); free(shellcmd); if (cdata->bflag) |