diff --git a/ChangeLog b/ChangeLog index e5bcc07a..c70403d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -62,6 +62,11 @@ CVS code (David Benbennick). colortoint, parse_colors() - Don't add strings with invalid fg colors at all. + do_rcfile() + - Revert (somewhat) previous behavior of looking at + $HOME, and only run getpw* if it is NULL. Most *nix programs + seem to only care about $HOME, and at the user-level + getpw* may not be reliable (and its slower). - search.c: do_gotoline() - Only goto_abort() if we *didnt* abort the command, making diff --git a/rcfile.c b/rcfile.c index 03f5dfee..829a1efb 100644 --- a/rcfile.c +++ b/rcfile.c @@ -635,20 +635,27 @@ void do_rcfile(void) } #endif - /* Determine home directory using getpwent(), don't rely on $HOME */ - do { - userage = getpwent(); - } while (userage != NULL && userage->pw_uid != euid); - endpwent(); - lineno = 0; - if (userage == NULL) { - rcfile_error(_("I can't find my home directory! Wah!")); - SET(NO_RCFILE); + /* Rely on $HOME, fall back on getpwuid() */ + if (getenv("HOME") != NULL) { + nanorc = nrealloc(nanorc, strlen(getenv("HOME")) + 10); + sprintf(nanorc, "%s/.nanorc", getenv("HOME")); } else { - nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9); - sprintf(nanorc, "%s/.nanorc", userage->pw_dir); + userage = getpwuid(euid); + endpwent(); + + if (userage == NULL) { + rcfile_error(_("I can't find my home directory! Wah!")); + SET(NO_RCFILE); + } else { + nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9); + sprintf(nanorc, "%s/.nanorc", userage->pw_dir); + + } + } + + if (!ISSET(NO_RCFILE)) { #if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING) /* If we've already read $SYSCONFDIR/nanorc (if it's there), we're