The branch, master has been updated
       via  a6ad44f111a42553ad38a850a0e215914ea1f037 (commit)
      from  97620bb5becf29571a8f5bd1ee89e0b12908f799 (commit)

- Log -----------------------------------------------------------------
commit a6ad44f111a42553ad38a850a0e215914ea1f037
Author: Nicholas Marriott <[email protected]>
Commit: Nicholas Marriott <[email protected]>

    Fix if-shell and run-shell if there are no sessions. Batted around through
    several people, finished off by Chris Johnsen.
---
 cmd-if-shell.c  |   20 +++++++++++---------
 cmd-run-shell.c |   29 ++++++++++++++++-------------
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index b921f41..b22e326 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);
 
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index aaa310b..b163542 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -49,16 +49,17 @@ struct cmd_run_shell_data {
        char            *cmd;
        struct cmd_q    *cmdq;
        int              bflag;
-       u_int            wp_id;
+       int              wp_id;
 };
 
 void
 cmd_run_shell_print(struct job *job, const char *msg)
 {
        struct cmd_run_shell_data       *cdata = job->data;
-       struct window_pane              *wp;
+       struct window_pane              *wp = NULL;
 
-       wp = window_pane_find_by_id(cdata->wp_id);
+       if (cdata->wp_id != -1)
+               wp = window_pane_find_by_id(cdata->wp_id);
        if (wp == NULL) {
                cmdq_print(cdata->cmdq, "%s", msg);
                return;
@@ -76,26 +77,28 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
        struct args                     *args = self->args;
        struct cmd_run_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);
 
        cdata = xmalloc(sizeof *cdata);
        cdata->cmd = shellcmd;
        cdata->bflag = args_has(args, 'b');
-       cdata->wp_id = wp->id;
+       cdata->wp_id = wp != NULL ? (int) wp->id : -1;
 
        cdata->cmdq = cmdq;
        cmdq->references++;


-----------------------------------------------------------------------

Summary of changes:
 cmd-if-shell.c  |   20 +++++++++++---------
 cmd-run-shell.c |   29 ++++++++++++++++-------------
 2 files changed, 27 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to