diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2015-07-24 09:10:21 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2015-07-24 09:10:21 +0100 |
commit | e4cdc9fa0b00d6fc691afcf2fc3f727e60dfe94c (patch) | |
tree | fc40662e40cb3ce8fa4d1b4a8650683b2e51b3b7 /tmux.c | |
parent | 669059aa19ec831e9a8afc008c978ea7806692e3 (diff) | |
parent | 18a64ad52d5b33e229783574a637268eb098b1f0 (diff) | |
download | rtmux-e4cdc9fa0b00d6fc691afcf2fc3f727e60dfe94c.tar.gz rtmux-e4cdc9fa0b00d6fc691afcf2fc3f727e60dfe94c.tar.bz2 rtmux-e4cdc9fa0b00d6fc691afcf2fc3f727e60dfe94c.zip |
Merge branch 'master' of github.com:tmux/tmux
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -200,10 +200,27 @@ shell_exec(const char *shell, const char *shellcmd) fatal("execl failed"); } +const char* +find_home(void) +{ + struct passwd *pw; + const char *home; + + home = getenv("HOME"); + if (home == NULL || *home == '\0') { + pw = getpwuid(getuid()); + if (pw != NULL) + home = pw->pw_dir; + else + home = NULL; + } + + return home; +} + int main(int argc, char **argv) { - struct passwd *pw; char *s, *path, *label, **var, tmp[PATH_MAX]; char in[256]; const char *home; @@ -325,14 +342,7 @@ main(int argc, char **argv) /* Locate the configuration file. */ if (cfg_file == NULL) { - home = getenv("HOME"); - if (home == NULL || *home == '\0') { - pw = getpwuid(getuid()); - if (pw != NULL) - home = pw->pw_dir; - else - home = NULL; - } + home = find_home(); if (home != NULL) { xasprintf(&cfg_file, "%s/.tmux.conf", home); if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { |