diff options
author | 2010-02-04 18:27:06 +0000 | |
---|---|---|
committer | 2010-02-04 18:27:06 +0000 | |
commit | 2fa50cfc60a9881764dbd74dd75e2232a23c7b47 (patch) | |
tree | 57c25c7be32492056fccf56d2cc307ba78337ff2 /usr.bin/tmux/tmux.c | |
parent | Option to display the active pane in a different colour with the display-panes (diff) | |
download | wireguard-openbsd-2fa50cfc60a9881764dbd74dd75e2232a23c7b47.tar.xz wireguard-openbsd-2fa50cfc60a9881764dbd74dd75e2232a23c7b47.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 'usr.bin/tmux/tmux.c')
-rw-r--r-- | usr.bin/tmux/tmux.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 76c27fd91b0..1aeeb408e2a 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -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 <nicm@users.sourceforge.net> @@ -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; |