mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
22198: do always set HOME in native emulation
This commit is contained in:
parent
90b6199e17
commit
30176eaf63
5 changed files with 38 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
|||
2006-02-07 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 22198: README, Src/init.c, Src/params.c, Doc/Zsh/params.yo:
|
||||
modify 22195 so that HOME gets set as before in native emulation.
|
||||
|
||||
2006-02-06 Wayne Davison <wayned@users.sourceforge.net>
|
||||
|
||||
* unposted: Src/Modules/newuser.c: fixed return-without-value
|
||||
|
@ -5,7 +10,7 @@
|
|||
|
||||
2006-02-06 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 22196: INSTALL, README, Config/version.mk: developement
|
||||
* 22196: INSTALL, README, Config/version.mk: development
|
||||
version 4.3.0-dev-3
|
||||
|
||||
* 22195: README, Src/init.c, Src/params.c, Src/subst.c,
|
||||
|
|
|
@ -805,7 +805,10 @@ cushion for saving duplicated history events.
|
|||
)
|
||||
vindex(HOME)
|
||||
item(tt(HOME) <S>)(
|
||||
The default argument for the tt(cd) command.
|
||||
The default argument for the tt(cd) command. This is not set automatically
|
||||
by the shell in tt(sh), tt(ksh) or tt(csh) emulation, but it is typically
|
||||
present in the environment anyway, and if it becomes set it has its usual
|
||||
special behaviour.
|
||||
)
|
||||
vindex(IFS)
|
||||
item(tt(IFS) <S>)(
|
||||
|
|
5
README
5
README
|
@ -31,8 +31,9 @@ variables as an error, so can still return status 0 (depending on the
|
|||
handling of other arguments). This appears to be the standard shell
|
||||
behaviour.
|
||||
|
||||
The variable HOME is no longer set by the shell; it must be present
|
||||
in the environment. It is valid for the variable to be unset.
|
||||
The variable HOME is no longer set by the shell if zsh is emulating any
|
||||
other shell at startup; it must be present in the environment or set
|
||||
subsequently by the user. It is valid for the variable to be unset.
|
||||
|
||||
Zsh has previously been lax about whether it allows octets with the
|
||||
top bit set to be part of a shell identifier. With --enable-multibyte set,
|
||||
|
|
19
Src/init.c
19
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)))
|
||||
|
|
11
Src/params.c
11
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);
|
||||
|
|
Loading…
Reference in a new issue