From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28882 invoked from network); 21 Feb 2008 18:24:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,MISSING_HEADERS autolearn=no version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Feb 2008 18:24:02 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 73597 invoked from network); 21 Feb 2008 18:23:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Feb 2008 18:23:26 -0000 Received: (qmail 20425 invoked by alias); 21 Feb 2008 18:23:17 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12632 Received: (qmail 20414 invoked from network); 21 Feb 2008 18:23:16 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 21 Feb 2008 18:23:16 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id B3C9E8026E0B for ; Thu, 21 Feb 2008 19:23:07 +0100 (CET) Received: from rly47d.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly47d.srv.mailcontrol.com (MailControl) with ESMTP id m1LIMvDn001906 for ; Thu, 21 Feb 2008 18:22:57 GMT Received: from submission.mailcontrol.com (submission.mailcontrol.com [86.111.216.190]) by rly47d.srv.mailcontrol.com (MailControl) id m1LIM0vB031585 for zsh-users@sunsite.dk; Thu, 21 Feb 2008 18:22:00 GMT Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly47d-eth0.srv.mailcontrol.com (envelope-sender Peter.Stephenson@csr.com) (MIMEDefang) with ESMTP id m1LILxpP031483; Thu, 21 Feb 2008 18:22:00 +0000 (GMT) Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 21 Feb 2008 18:21:49 +0000 Date: Thu, 21 Feb 2008 18:21:49 +0000 From: Peter Stephenson Cc: zsh-users@sunsite.dk, 317773@bugs.debian.org Subject: Re: LC_ALL=C foo, where foo is a shell function Message-ID: <20080221182149.12e390e0@news01> In-Reply-To: <20070414193812.GA9936@scowler.net> References: <20050709191401.GP6472@ay.vinc17.org> <1050709204433.ZM17965@candle.brasslantern.com> <20050710000436.GS6472@ay.vinc17.org> <1050710005748.ZM18160@candle.brasslantern.com> <20070414193812.GA9936@scowler.net> Organization: CSR X-Mailer: Claws Mail 3.3.0 (GTK+ 2.12.5; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 21 Feb 2008 18:21:49.0416 (UTC) FILETIME=[9FD05680:01C874B6] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.68.1.157 X-Virus-Scanned: ClamAV 0.91.2/5918/Thu Feb 21 16:33:07 2008 on bifrost X-Virus-Status: Clean On Sun, Jul 10, 2005 at 12:57:47AM +0000, Bart Schaefer wrote: > I just noticed that, even in the latest build, if LC_ALL starts out set > (even to nothing), but not exported, then when "LC_ALL=C foo" is run > LC_ALL becomes and remains exported, even though its value gets reset > to the previous state. There are two completely separate parts of the shell that restore parameters. There is one I wrote for function scope, and there is a second one that someone else wrote without taking any notice of the first one that restores parameters in this case. (Good job I never get bitter, eh?) This second one doesn't take account of restoring a special parameter when the local value is exported and the old value isn't. For specials there is always an entry in the table, so this applies even if LC_ALL isn't actually set. It should just be a case of removing stuff from the environment if we know it shouldn't be there. I can't see any cases when this would be wrong, anyway. (There are POSIX exceptions, which I don't think cover LC_ALL anyway, where the value is preserved after the function call, but none that would force an export to be inconsistent with the local value.) Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.128 diff -u -r1.128 exec.c --- Src/exec.c 9 Dec 2007 23:53:33 -0000 1.128 +++ Src/exec.c 21 Feb 2008 18:14:41 -0000 @@ -3113,6 +3113,8 @@ DPUTS(!tpm || PM_TYPE(pm->node.flags) != PM_TYPE(tpm->node.flags) || !(pm->node.flags & PM_SPECIAL), "BUG: in restoring special parameters"); + if (!pm->env && tpm->env) + delenv(tpm); tpm->node.flags = pm->node.flags; switch (PM_TYPE(pm->node.flags)) { case PM_SCALAR: -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070