Hi,

On Tue, Feb 26, 2013 at 06:37:19PM +0000, Ben Boeckel wrote:
> Hi,
> 
> I updated to the newest master recently and it seems as though the
> synchronous if-shell support has broken usage of it from ~/.tmux.conf.
> At the end of my .tmux.conf I have the following:
> 
> # 256-color support
> if-shell -b 'test "`tput colors`" -eq 256' 'source-file 
> "$XDG_CONFIG_HOME/tmux/256-colors"'
> if-shell -b 'test "`tput Co`" -eq 256' 'source-file 
> "$XDG_CONFIG_HOME/tmux/256-colors"'
> 
> With the new if-shell, I get:
> 
> /home/boeckb/.tmux.conf:120: can't establish current session
> /home/boeckb/.tmux.conf:121: can't establish current session

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():

        wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
        if (wl == NULL)
                return (CMD_RETURN_ERROR);

Which is bogus, because the only time a winlink is ever useful is if we've
asked to use one via -t, which is both optional, and in most people's config
files won't return anything useful for sever startup.  Its check for being
NULL is useful only when trying to parse format lines.

So I think the following patch should help fix things for you:

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

A similar change will be needed for cmd-run-shell.c should this sort of thing 
work OK for you.

-- Thomas Adam

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