diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-08-30 22:56:37 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-08-30 22:56:37 +0000 |
commit | 567ee0731c4d461f8ba50ec4c1eda541509e5e17 (patch) | |
tree | e6c575749d4960f50e4a9feec24428f2436bf014 /usr.bin | |
parent | 5b5a9ec4f5a3306168b4b65563a465f2378de889 (diff) |
Path from $TMUX does not need to be global anymore.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/tmux.c | 28 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
2 files changed, 15 insertions, 16 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 109b9f47081..560039c4c25 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.140 2015/08/30 22:40:25 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.141 2015/08/30 22:56:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -46,7 +46,6 @@ char *shell_cmd; int debug_level; time_t start_time; char socket_path[PATH_MAX]; -char *environ_path; __dead void usage(void); char *makesocketpath(const char *); @@ -191,10 +190,8 @@ int main(int argc, char **argv) { char *s, *path, *label, **var, tmp[PATH_MAX]; - char in[256]; const char *home; - long long pid; - int opt, flags, keys, session; + int opt, flags, keys; #ifdef DEBUG malloc_options = (char *) "AFGJPX"; @@ -321,11 +318,6 @@ main(int argc, char **argv) } } - /* Get path from environment. */ - s = getenv("TMUX"); - if (s != NULL && sscanf(s, "%255[^,],%lld,%d", in, &pid, &session) == 3) - environ_path = xstrdup(in); - /* * Figure out the socket path. If specified on the command-line with -S * or -L, use it, otherwise try $TMUX or assume -L default. @@ -333,8 +325,15 @@ main(int argc, char **argv) if (path == NULL) { /* If no -L, use the environment. */ if (label == NULL) { - if (environ_path != NULL) - path = xstrdup(environ_path); + s = getenv("TMUX"); + if (s != NULL) { + path = xstrdup(s); + path[strcspn (path, ",")] = '\0'; + if (*path == '\0') { + free(path); + label = xstrdup("default"); + } + } else label = xstrdup("default"); } @@ -343,14 +342,15 @@ main(int argc, char **argv) if (label != NULL) { if ((path = makesocketpath(label)) == NULL) { fprintf(stderr, "can't create socket: %s\n", - strerror(errno)); + strerror(errno)); exit(1); } } } free(label); - if (strlcpy(socket_path, path, sizeof socket_path) >= sizeof socket_path) { + if (strlcpy(socket_path, path, sizeof socket_path) >= + sizeof socket_path) { fprintf(stderr, "socket path too long: %s\n", path); exit(1); } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 7da757fe604..7afa68c2163 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.547 2015/08/30 22:40:25 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.548 2015/08/30 22:56:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1412,7 +1412,6 @@ extern char *shell_cmd; extern int debug_level; extern time_t start_time; extern char socket_path[PATH_MAX]; -extern char *environ_path; void logfile(const char *); const char *getshell(void); int checkshell(const char *); |