diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-02-26 09:36:43 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-02-26 09:36:43 -0500 |
commit | ac50fbac377e32b98d2de396f016ea81e8ee9961 (patch) | |
tree | f71882366b98fedf1a88a063103219a4935de926 /lib/tilde | |
parent | 4539d736f1aff232857a854fd2a68df0c98d9f34 (diff) | |
download | android_external_bash-ac50fbac377e32b98d2de396f016ea81e8ee9961.tar.gz android_external_bash-ac50fbac377e32b98d2de396f016ea81e8ee9961.tar.bz2 android_external_bash-ac50fbac377e32b98d2de396f016ea81e8ee9961.zip |
Bash-4.3 distribution sources and documentation
Diffstat (limited to 'lib/tilde')
-rw-r--r-- | lib/tilde/shell.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c index 40a95b6..fafb861 100644 --- a/lib/tilde/shell.c +++ b/lib/tilde/shell.c @@ -55,15 +55,26 @@ get_env_value (varname) return ((char *)getenv (varname)); } +/* If we're not using $HOME, assume that the passwd file information won't + change while this shell instance is running. */ char * get_home_dir () { - char *home_dir; + static char *home_dir = (char *)NULL; struct passwd *entry; - home_dir = (char *)NULL; + if (home_dir) + return (home_dir); + +#if defined (HAVE_GETPWUID) entry = getpwuid (getuid ()); if (entry) - home_dir = entry->pw_dir; + home_dir = savestring (entry->pw_dir); +#endif + +#if defined (HAVE_GETPWENT) + endpwent (); /* some systems need this */ +#endif + return (home_dir); } |