From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15648 invoked from network); 6 Feb 2006 11:19:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Feb 2006 11:19:53 -0000 Received: (qmail 40864 invoked from network); 6 Feb 2006 11:19:47 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Feb 2006 11:19:47 -0000 Received: (qmail 13949 invoked by alias); 6 Feb 2006 11:19:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22195 Received: (qmail 13940 invoked from network); 6 Feb 2006 11:19:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 6 Feb 2006 11:19:44 -0000 Received: (qmail 40593 invoked from network); 6 Feb 2006 11:19:44 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 6 Feb 2006 11:19:42 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly13d.srv.mailcontrol.com (MailControl) with ESMTP id k16BI3VR022112 for ; Mon, 6 Feb 2006 11:19:18 GMT Received: from csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 6 Feb 2006 11:17:40 +0000 To: zsh-workers@sunsite.dk Subject: Re: Is a pristine shell allowed to set HOME? (fwd) In-reply-to: References: Comments: In-reply-to Bart Schaefer message dated "Sun, 05 Feb 2006 12:44:40 -0800." Date: Mon, 06 Feb 2006 11:17:27 +0000 From: Peter Stephenson Message-ID: X-OriginalArrivalTime: 06 Feb 2006 11:17:40.0590 (UTC) FILETIME=[F161E8E0:01C62B0E] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-06-00-01 (www.mailcontrol.com) on 10.68.0.123 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 > To: austin-group-l@opengroup.org > 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 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