diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-02-04 18:27:06 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-02-04 18:27:06 +0000 |
commit | e7c6f81016f304241d11e9c4313f2d7257d6ef24 (patch) | |
tree | 268c33c7313d3192b0346d5dfcc068c22bd0c138 /tmux.c | |
parent | 604b02cfaa59cf65623b828baf310b5998674cd0 (diff) | |
download | rtmux-e7c6f81016f304241d11e9c4313f2d7257d6ef24.tar.gz rtmux-e7c6f81016f304241d11e9c4313f2d7257d6ef24.tar.bz2 rtmux-e7c6f81016f304241d11e9c4313f2d7257d6ef24.zip |
Read the path from $TMUX if it is present and -L and -S are not given. Based on
a diff from Micah Cowan.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -443,13 +443,30 @@ 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); + if (label != NULL) + xfree(label); if (shellcmd != NULL) { msg = MSG_SHELL; |