version 1.80, 2020/04/13 15:55:51 |
version 1.81, 2020/05/16 14:26:33 |
|
|
cfg_file = xstrdup(path); |
cfg_file = xstrdup(path); |
} |
} |
|
|
static char * |
|
expand_cfg_file(const char *path, const char *home) |
|
{ |
|
char *expanded, *name; |
|
const char *end; |
|
struct environ_entry *value; |
|
|
|
if (strncmp(path, "~/", 2) == 0) { |
|
if (home == NULL) |
|
return (NULL); |
|
xasprintf(&expanded, "%s%s", home, path + 1); |
|
return (expanded); |
|
} |
|
|
|
if (*path == '$') { |
|
end = strchr(path, '/'); |
|
if (end == NULL) |
|
name = xstrdup(path + 1); |
|
else |
|
name = xstrndup(path + 1, end - path - 1); |
|
value = environ_find(global_environ, name); |
|
free(name); |
|
if (value == NULL) |
|
return (NULL); |
|
if (end == NULL) |
|
end = ""; |
|
xasprintf(&expanded, "%s%s", value->value, end); |
|
return (expanded); |
|
} |
|
|
|
return (xstrdup(path)); |
|
} |
|
|
|
void |
void |
start_cfg(void) |
start_cfg(void) |
{ |
{ |
const char *home = find_home(); |
struct client *c; |
struct client *c; |
char **paths; |
char *path, *copy, *next, *expanded; |
u_int i, n; |
|
|
/* |
/* |
* Configuration files are loaded without a client, so commands are run |
* Configuration files are loaded without a client, so commands are run |
|
|
} |
} |
|
|
if (cfg_file == NULL) { |
if (cfg_file == NULL) { |
path = copy = xstrdup(TMUX_CONF); |
expand_paths(TMUX_CONF, &paths, &n); |
while ((next = strsep(&path, ":")) != NULL) { |
for (i = 0; i < n; i++) { |
expanded = expand_cfg_file(next, home); |
load_cfg(paths[i], c, NULL, CMD_PARSE_QUIET, NULL); |
if (expanded == NULL) { |
free(paths[i]); |
log_debug("couldn't expand %s", next); |
|
continue; |
|
} |
|
log_debug("expanded %s to %s", next, expanded); |
|
load_cfg(expanded, c, NULL, CMD_PARSE_QUIET, NULL); |
|
free(expanded); |
|
} |
} |
free(copy); |
free(paths); |
} else |
} else |
load_cfg(cfg_file, c, NULL, 0, NULL); |
load_cfg(cfg_file, c, NULL, 0, NULL); |
|
|