How about this instead? I think it should have the same effect. Index: tmux.c =================================================================== RCS file: /cvs/src/usr.bin/tmux/tmux.c,v retrieving revision 1.66 diff -u -p -r1.66 tmux.c --- tmux.c 3 Jan 2010 12:51:05 -0000 1.66 +++ tmux.c 3 Feb 2010 21:55:27 -0000 @@ -442,13 +442,29 @@ main(int argc, char **argv) } } - if (label == NULL) - label = xstrdup("default"); - if (path == NULL && (path = makesockpath(label)) == NULL) { - log_warn("can't create socket"); - exit(1); + /* + * Figure out the socket path. If specified on the command-line with + * -S or -L, use it, otherwise try $TMUX or assume -L default. + */ + if (path == NULL) { + /* No -L. Try $TMUX, or default. */ + if (label == NULL) { + if ((path = getenv("TMUX")) != NULL) { + path = xstrdup(path); + path[strcspn(path, ",")] = '\0'; + } else + label = xstrdup("default"); + } + + /* -L or default set. */ + if (label != NULL) { + if ((path = makesockpath(label)) == NULL) { + log_warn("can't create socket"); + exit(1); + } + xfree(label); + } } - xfree(label); if (shellcmd != NULL) { msg = MSG_SHELL;
On Wed, Feb 03, 2010 at 08:29:00AM -0800, Micah Cowan wrote: > Understood. I wasn't sure you would; I just dislike duplicating the same > > if ((path = makesockpath(...)) == NULL) { > give_an_error_msg(); > exit(1); > } > > twice in a row (once in one branch, and again in a branch of an outer > if, IIRC - wherever the xmakesockpath calls are now). And avoiding the > double with either an extra flag var (which I know you're not crazy > about) or a goto looked even uglier to me. Maybe you'll find a solution > you like better. > > -mjc > > Nicholas Marriott wrote: > > Nice idea, will have a better look tonight but I'm not sure I like > > the idea of makesockpath calling exit(). ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users