diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-03-11 09:43:56 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-03-11 09:43:56 +0000 |
commit | a6ad44f111a42553ad38a850a0e215914ea1f037 (patch) | |
tree | 8d58e985644e853f406bff9d3393a066c1494d53 /cmd-if-shell.c | |
parent | 97620bb5becf29571a8f5bd1ee89e0b12908f799 (diff) | |
download | rtmux-a6ad44f111a42553ad38a850a0e215914ea1f037.tar.gz rtmux-a6ad44f111a42553ad38a850a0e215914ea1f037.tar.bz2 rtmux-a6ad44f111a42553ad38a850a0e215914ea1f037.zip |
Fix if-shell and run-shell if there are no sessions. Batted around through
several people, finished off by Chris Johnsen.
Diffstat (limited to 'cmd-if-shell.c')
-rw-r--r-- | cmd-if-shell.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/cmd-if-shell.c b/cmd-if-shell.c index b921f418..b22e3269 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); |