From 71c590a37f98d82c72279eddae74f9b8be146202 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 17 Jan 2021 16:17:41 +0000 Subject: Add -N flag to never start server even if command would normally do so, GitHub issue 2523. --- tmux.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index b7fc5121..5861e66b 100644 --- a/tmux.c +++ b/tmux.c @@ -57,7 +57,7 @@ static __dead void usage(void) { fprintf(stderr, - "usage: %s [-2CDluvV] [-c shell-command] [-f file] [-L socket-name]\n" + "usage: %s [-2CDlNuvV] [-c shell-command] [-f file] [-L socket-name]\n" " [-S socket-path] [-T features] [command [flags]]\n", getprogname()); exit(1); @@ -350,7 +350,7 @@ main(int argc, char **argv) if (**argv == '-') flags = CLIENT_LOGIN; - while ((opt = getopt(argc, argv, "2c:CDdf:lL:qS:T:uUvV")) != -1) { + while ((opt = getopt(argc, argv, "2c:CDdf:lL:NqS:T:uUvV")) != -1) { switch (opt) { case '2': tty_add_features(&feat, "256", ":,"); @@ -380,6 +380,9 @@ main(int argc, char **argv) free(label); label = xstrdup(optarg); break; + case 'N': + flags |= CLIENT_NOSTARTSERVER; + break; case 'q': break; case 'S': -- cgit From a3011be0d267a090c8bfa01a4ebe093bc203a1c4 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 17 Jan 2021 17:21:51 +0000 Subject: Look for libevent2 differently from libevent for platforms with both. --- tmux.c | 1 - 1 file changed, 1 deletion(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index 066714df..96b94e01 100644 --- a/tmux.c +++ b/tmux.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include -- cgit From 6876381276ff2c2a40d304ada27651fdaf1cd8a7 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 22 Feb 2021 08:18:13 +0000 Subject: Move config file path expansion much earlier, keep the list of paths around rather than freeing later, and add a config_files format variable containing it. Suggested by kn@ a while back. --- tmux.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index 5861e66b..fb908031 100644 --- a/tmux.c +++ b/tmux.c @@ -142,11 +142,12 @@ expand_path(const char *path, const char *home) return (xstrdup(path)); } -void -expand_paths(const char *s, char ***paths, u_int *n) +static void +expand_paths(const char *s, char ***paths, u_int *n, int ignore_errors) { const char *home = find_home(); char *copy, *next, *tmp, resolved[PATH_MAX], *expanded; + char *path; u_int i; *paths = NULL; @@ -162,20 +163,26 @@ expand_paths(const char *s, char ***paths, u_int *n) if (realpath(expanded, resolved) == NULL) { log_debug("%s: realpath(\"%s\") failed: %s", __func__, expanded, strerror(errno)); + if (ignore_errors) { + free(expanded); + continue; + } + path = expanded; + } else { + path = xstrdup(resolved); free(expanded); - continue; } - free(expanded); for (i = 0; i < *n; i++) { - if (strcmp(resolved, (*paths)[i]) == 0) + if (strcmp(path, (*paths)[i]) == 0) break; } if (i != *n) { - log_debug("%s: duplicate path: %s", __func__, resolved); + log_debug("%s: duplicate path: %s", __func__, path); + free(path); continue; } *paths = xreallocarray(*paths, (*n) + 1, sizeof *paths); - (*paths)[(*n)++] = xstrdup(resolved); + (*paths)[(*n)++] = path; } free(copy); } @@ -193,7 +200,7 @@ make_label(const char *label, char **cause) label = "default"; uid = getuid(); - expand_paths(TMUX_SOCK, &paths, &n); + expand_paths(TMUX_SOCK, &paths, &n, 1); if (n == 0) { xasprintf(cause, "no suitable socket path"); return (NULL); @@ -330,10 +337,11 @@ main(int argc, char **argv) { char *path = NULL, *label = NULL; char *cause, **var; - const char *s, *shell, *cwd; + const char *s, *cwd; int opt, keys, feat = 0; uint64_t flags = 0; const struct options_table_entry *oe; + u_int i; if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL && setlocale(LC_CTYPE, "C.UTF-8") == NULL) { @@ -349,6 +357,7 @@ main(int argc, char **argv) if (**argv == '-') flags = CLIENT_LOGIN; + expand_paths(TMUX_CONF, &cfg_files, &cfg_nfiles, 1); while ((opt = getopt(argc, argv, "2c:CDdf:lL:NqS:T:uUvV")) != -1) { switch (opt) { @@ -368,7 +377,11 @@ main(int argc, char **argv) flags |= CLIENT_CONTROL; break; case 'f': - set_cfg_file(optarg); + for (i = 0; i < cfg_nfiles; i++) + free(cfg_files[i]); + free(cfg_files); + expand_paths(optarg, &cfg_files, &cfg_nfiles, 0); + cfg_quiet = 0; break; case 'V': printf("%s %s\n", getprogname(), getversion()); @@ -460,8 +473,8 @@ main(int argc, char **argv) * The default shell comes from SHELL or from the user's passwd entry * if available. */ - shell = getshell(); - options_set_string(global_s_options, "default-shell", 0, "%s", shell); + options_set_string(global_s_options, "default-shell", 0, "%s", + getshell()); /* Override keys to vi if VISUAL or EDITOR are set. */ if ((s = getenv("VISUAL")) != NULL || (s = getenv("EDITOR")) != NULL) { -- cgit From 6d8efe9319857c0b1bc49118248efe7f55112bb5 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 22 Feb 2021 11:42:50 +0000 Subject: expand_paths needs the global environment to be set up, do that first. --- tmux.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index fb908031..71cbccba 100644 --- a/tmux.c +++ b/tmux.c @@ -357,6 +357,12 @@ main(int argc, char **argv) if (**argv == '-') flags = CLIENT_LOGIN; + + global_environ = environ_create(); + for (var = environ; *var != NULL; var++) + environ_put(global_environ, *var, 0); + if ((cwd = find_cwd()) != NULL) + environ_set(global_environ, "PWD", 0, "%s", cwd); expand_paths(TMUX_CONF, &cfg_files, &cfg_nfiles, 1); while ((opt = getopt(argc, argv, "2c:CDdf:lL:NqS:T:uUvV")) != -1) { @@ -451,12 +457,6 @@ main(int argc, char **argv) flags |= CLIENT_UTF8; } - global_environ = environ_create(); - for (var = environ; *var != NULL; var++) - environ_put(global_environ, *var, 0); - if ((cwd = find_cwd()) != NULL) - environ_set(global_environ, "PWD", 0, "%s", cwd); - global_options = options_create(NULL); global_s_options = options_create(NULL); global_w_options = options_create(NULL); -- cgit