This is fine for if-shell but wrong for run-shell because wp can't be
NULL, it is deferenced a bit later in the function. I suggest making
wp_id signed and setting it to -1 if the output should be discarded in
cmd_run_shell_print.


On Wed, Feb 27, 2013 at 11:28:01AM -0500, Ben Boeckel wrote:
> On Tue, Feb 26, 2013 at 19:55:39 +0000, Thomas Adam wrote:
> > This is, I presume, only when the server is initially started, yes?  That
> > makes sense because here we see in cmd-if-shell.c:cmd_if_shell_exec():
> 
> Yes.
> 
> <snip patch>
> 
> Yep, that works. Patch attached which applied (I'm guessing the inlining
> mangled something) and with run-shell updated as well.
> 
> Thanks,
> 
> --Ben

> diff --git a/cmd-if-shell.c b/cmd-if-shell.c
> index b921f41..4d3e340 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..5f34ee9 100644
> --- a/cmd-run-shell.c
> +++ b/cmd-run-shell.c
> @@ -76,19 +76,21 @@ 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);
>  

> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb

> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to