about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-02-07 11:29:30 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-02-07 11:29:30 +0000
commit30176eaf635a61d77114f5e834ed0684ea7dac05 (patch)
tree344141169d7c46c58a5c74bca2b81d17862fd0ac /Src
parent90b6199e17c437408192966a3ff8266db9a4b1c2 (diff)
downloadzsh-30176eaf635a61d77114f5e834ed0684ea7dac05.tar.gz
zsh-30176eaf635a61d77114f5e834ed0684ea7dac05.tar.xz
zsh-30176eaf635a61d77114f5e834ed0684ea7dac05.zip
22198: do always set HOME in native emulation
Diffstat (limited to 'Src')
-rw-r--r--Src/init.c19
-rw-r--r--Src/params.c11
2 files changed, 25 insertions, 5 deletions
diff --git a/Src/init.c b/Src/init.c
index adb6eb84a..ac04a90e2 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -798,19 +798,28 @@ setupvals(void)
     /* Get password entry and set info for `USERNAME' */
 #ifdef HAVE_GETPWUID
     if ((pswd = getpwuid(cached_uid))) {
+	if (emulation == EMULATE_ZSH)
+	    home = metafy(pswd->pw_dir, -1, META_DUP);
 	cached_username = ztrdup(pswd->pw_name);
-    } else
+    }
+    else
 #endif /* HAVE_GETPWUID */
-	   {
+    {
+	if (emulation == EMULATE_ZSH)
+	    home = ztrdup("/");
 	cached_username = ztrdup("");
     }
 
     /*
      * Try a cheap test to see if we can initialize `PWD' from `HOME'.
-     * HOME must come from the environment; we're not allowed to
-     * set it locally.
+     * In non-native emulations HOME must come from the environment;
+     * we're not allowed to set it locally.
      */
-    if ((ptr = getenv("HOME")) && ispwd(ptr))
+    if (emulation == EMULATE_ZSH)
+	ptr = home;
+    else
+	ptr = getenv("HOME");
+    if (ptr && ispwd(ptr))
 	pwd = ztrdup(ptr);
     else if ((ptr = zgetenv("PWD")) && (strlen(ptr) < PATH_MAX) &&
 	     (ptr = metafy(ptr, -1, META_STATIC), ispwd(ptr)))
diff --git a/Src/params.c b/Src/params.c
index 5e4231cac..a633fb579 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -690,6 +690,17 @@ createparamtable(void)
     *envp = '\0';
     opts[ALLEXPORT] = oae;
 
+    if (emulation == EMULATE_ZSH)
+    {
+	/*
+	 * For native emulation we always set the variable home
+	 * (see setupvals()).
+	 */
+	pm = (Param) paramtab->getnode(paramtab, "HOME");
+	pm->flags &= ~PM_UNSET;
+	if (!(pm->flags & PM_EXPORTED))
+	    addenv(pm, home);
+    }
     pm = (Param) paramtab->getnode(paramtab, "LOGNAME");
     if (!(pm->flags & PM_EXPORTED))
 	addenv(pm, pm->u.str);