=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tmux.c,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- src/usr.bin/tmux/tmux.c 2010/02/04 18:20:16 1.67 +++ src/usr.bin/tmux/tmux.c 2010/02/04 18:27:06 1.68 @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.67 2010/02/04 18:20:16 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.68 2010/02/04 18:27:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -443,13 +443,30 @@ } } - 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); + if (label != NULL) + xfree(label); if (shellcmd != NULL) { msg = MSG_SHELL;