aboutsummaryrefslogtreecommitdiff
path: root/tmux.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-02-05 01:32:10 +0000
committerTiago Cunha <tcunha@gmx.com>2010-02-05 01:32:10 +0000
commitd398bbc53be4a6f65346e70e9bdfc797ad583528 (patch)
treeaeee8beb9447f214b0d9a15001a996ae039ac702 /tmux.c
parent82ba7e69ec7386490a98cba8b54acb36f3691f0e (diff)
downloadrtmux-d398bbc53be4a6f65346e70e9bdfc797ad583528.tar.gz
rtmux-d398bbc53be4a6f65346e70e9bdfc797ad583528.tar.bz2
rtmux-d398bbc53be4a6f65346e70e9bdfc797ad583528.zip
Sync OpenBSD patchset 633:
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.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/tmux.c b/tmux.c
index a82e5af6..ba6072e6 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.198 2010-02-05 01:31:06 tcunha Exp $ */
+/* $Id: tmux.c,v 1.199 2010-02-05 01:32:10 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -446,13 +446,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;