Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is a pristine shell allowed to set HOME? (fwd)
- X-seq: zsh-workers 22195
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Is a pristine shell allowed to set HOME? (fwd)
- Date: Mon, 06 Feb 2006 11:17:27 +0000
- In-reply-to: <Pine.LNX.4.64.0602051243550.4756@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <Pine.LNX.4.64.0602051243550.4756@xxxxxxxxxxxxxxxxxx>
Bart Schaefer wrote:
> Zsh seems to be the odd man out, here.
>
> ---------- Forwarded message ----------
> Date: Sun, 5 Feb 2006 20:14:07 +0100
> From: Jens Schweikhardt <schweikh@xxxxxxxxxxxxxxxx>
> To: austin-group-l@xxxxxxxxxxxxx
> Subject: Is a pristine shell allowed to set HOME?
> # env -i /bin/sh -c set | grep ^HOME=
> # env -i /usr/local/bin/bash -c set | grep ^HOME=
> # env -i /usr/local/bin/zsh -c set|grep ^HOME=
> HOME=/root
> # env -i /usr/local/bin/ksh93 -c set|grep ^HOME=
> # env -i /usr/local/bin/pdksh -c set|grep ^HOME=
> # env -i /bin/csh -c 'echo $HOME' # = tcsh
> HOME: Undefined variable.
Probably better to be compatible here... hope this doesn't break
anything, but it's a very unusual case.
Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.23
diff -u -r1.23 README
--- README 3 Oct 2005 09:00:45 -0000 1.23
+++ README 6 Feb 2006 11:13:29 -0000
@@ -31,6 +31,9 @@
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.
+
Documentation
-------------
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.61
diff -u -r1.61 init.c
--- Src/init.c 3 Dec 2005 00:14:06 -0000 1.61
+++ Src/init.c 6 Feb 2006 11:13:30 -0000
@@ -795,22 +795,23 @@
* recheck the info for `USERNAME' */
cached_uid = getuid();
- /* Get password entry and set info for `HOME' and `USERNAME' */
+ /* Get password entry and set info for `USERNAME' */
#ifdef HAVE_GETPWUID
if ((pswd = getpwuid(cached_uid))) {
- home = metafy(pswd->pw_dir, -1, META_DUP);
cached_username = ztrdup(pswd->pw_name);
} else
#endif /* HAVE_GETPWUID */
{
- home = ztrdup("/");
cached_username = ztrdup("");
}
- /* Try a cheap test to see if we can *
- * initialize `PWD' from `HOME' */
- if (ispwd(home))
- pwd = ztrdup(home);
+ /*
+ * 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.
+ */
+ if ((ptr = getenv("HOME")) && ispwd(ptr))
+ pwd = ztrdup(ptr);
else if ((ptr = zgetenv("PWD")) && (strlen(ptr) < PATH_MAX) &&
(ptr = metafy(ptr, -1, META_STATIC), ispwd(ptr)))
pwd = ztrdup(ptr);
@@ -1105,8 +1106,11 @@
queue_signals();
if (emulation == EMULATE_SH || emulation == EMULATE_KSH ||
- !(h = getsparam("ZDOTDIR")))
+ !(h = getsparam("ZDOTDIR"))) {
h = home;
+ if (!h)
+ return;
+ }
{
/* Let source() complain if path is too long */
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.107
diff -u -r1.107 params.c
--- Src/params.c 7 Nov 2005 09:37:34 -0000 1.107
+++ Src/params.c 6 Feb 2006 11:13:31 -0000
@@ -257,7 +257,7 @@
IPDEF2("USERNAME", username_gsu, PM_DONTIMPORT|PM_RESTRICTED),
IPDEF2("-", dash_gsu, PM_READONLY),
IPDEF2("histchars", histchars_gsu, PM_DONTIMPORT),
-IPDEF2("HOME", home_gsu, 0),
+IPDEF2("HOME", home_gsu, PM_UNSET),
IPDEF2("TERM", term_gsu, 0),
IPDEF2("WORDCHARS", wordchars_gsu, 0),
IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT),
@@ -690,9 +690,6 @@
*envp = '\0';
opts[ALLEXPORT] = oae;
- pm = (Param) paramtab->getnode(paramtab, "HOME");
- if (!(pm->flags & PM_EXPORTED))
- addenv(pm, home);
pm = (Param) paramtab->getnode(paramtab, "LOGNAME");
if (!(pm->flags & PM_EXPORTED))
addenv(pm, pm->u.str);
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.43
diff -u -r1.43 subst.c
--- Src/subst.c 1 Nov 2005 18:04:25 -0000 1.43
+++ Src/subst.c 6 Feb 2006 11:13:32 -0000
@@ -417,7 +417,7 @@
val = zstrtol(str + 1, &ptr, 10);
if (isend(str[1])) { /* ~ */
- *namptr = dyncat(home, str + 1);
+ *namptr = dyncat(home ? home : "", str + 1);
return 1;
} else if (str[1] == '+' && isend(str[2])) { /* ~+ */
*namptr = dyncat(pwd, str + 2);
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.115
diff -u -r1.115 utils.c
--- Src/utils.c 13 Jan 2006 17:13:49 -0000 1.115
+++ Src/utils.c 6 Feb 2006 11:13:34 -0000
@@ -630,8 +630,8 @@
* whenever a node is added to or removed from the hash table, and *
* whenever the value of $HOME changes. (On startup, too.) */
if (!s) {
- homenode.dir = home;
- homenode.diff = strlen(home);
+ homenode.dir = home ? home : "";
+ homenode.diff = home ? strlen(home) : 0;
if(homenode.diff==1)
homenode.diff = 0;
if(!finddir_full)
Index: Src/Modules/newuser.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/newuser.c,v
retrieving revision 1.3
diff -u -r1.3 newuser.c
--- Src/Modules/newuser.c 10 Dec 2005 00:27:11 -0000 1.3
+++ Src/Modules/newuser.c 6 Feb 2006 11:13:34 -0000
@@ -67,8 +67,11 @@
if (emulation != EMULATE_ZSH)
return 0;
- if (!dotdir)
+ if (!dotdir) {
dotdir = home;
+ if (!dotdir)
+ return;
+ }
if (check_dotfile(dotdir, ".zshenv") == 0 ||
check_dotfile(dotdir, ".zprofile") == 0 ||
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author