diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2016-06-12 08:07:44 +0200 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2016-06-12 08:12:00 +0200 |
commit | 2f7bb2cb5ea670b9dc4ef6acd3136af9f024b65c (patch) | |
tree | 1f8f30109ba1e5962ba66c0b2e5a9e9c889d39d8 | |
parent | a7db3b88bd0a9cc60e3e6b9c2ab03df2b510f3dc (diff) | |
download | ratpoison-2f7bb2cb5ea670b9dc4ef6acd3136af9f024b65c.zip |
Read the system config even if the homedir can't be found.
-rw-r--r-- | src/main.c | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -431,38 +431,41 @@ read_startup_files (const char *alt_rcfile) } else { - /* first check $HOME/.ratpoisonrc and if that does not exist then try - $sysconfdir/ratpoisonrc */ const char *homedir; + char *filename; + /* first check $HOME/.ratpoisonrc */ homedir = get_homedir (); - if (!homedir) PRINT_ERROR (("ratpoison: no home directory!?\n")); else { - char *filename; filename = xsprintf ("%s/.ratpoisonrc", homedir); - if ((fileptr = fopen (filename, "r")) == NULL) { if (errno != ENOENT) PRINT_ERROR (("ratpoison: could not open %s (%s)\n", filename, strerror (errno))); + } + free (filename); + } - free (filename); - filename = xsprintf ("%s/ratpoisonrc", SYSCONFDIR); + if (fileptr == NULL) + { + /* couldn't open $HOME/.ratpoisonrc, fall back on system config */ + filename = xsprintf ("%s/ratpoisonrc", SYSCONFDIR); - if ((fileptr = fopen (filename, "r")) == NULL) - if (errno != ENOENT) - PRINT_ERROR (("ratpoison: could not open %s (%s)\n", - filename, strerror (errno))); + if ((fileptr = fopen (filename, "r")) == NULL) + { + if (errno != ENOENT) + PRINT_ERROR (("ratpoison: could not open %s (%s)\n", + filename, strerror (errno))); } free (filename); } } - if (fileptr) + if (fileptr != NULL) { set_close_on_exec (fileno (fileptr)); read_rc_file (fileptr); |