From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id AAA06576 for ; Thu, 11 Jul 1996 00:18:23 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id JAA03332; Wed, 10 Jul 1996 09:45:54 -0400 (EDT) Resent-Date: Wed, 10 Jul 1996 09:45:54 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199607101345.PAA22038@bolyai.cs.elte.hu> Subject: Re: Bug Report: Env Vars and shell functions To: acs@world.std.com Date: Wed, 10 Jul 1996 15:45:03 +0200 (MET DST) Cc: pws@ifh.de, zsh-workers@math.gatech.edu In-Reply-To: <199607101219.IAA25984@spacely.icd.teradyne.com> from Vinnie Shelton at "Jul 10, 96 08:19:34 am" Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL16 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"FT6XG1.0.xp.HGxun"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1598 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > There's still a bug here; with 3.0-pre2 and only Peter's patch from > article 1573 and Zoltan's fix from article 1596, here's what happens: > > : zsh-3.0-pre2/Solaris Wed 10 8:08; env - /pd/osbin/zsh -f > spacely% echo $ZSH_VERSION > 3.0-pre2 > spacely% function foo { > > echo "Function foo; FOO = $FOO" > > ./x > > } > spacely% cat ./x > #!/pd/osbin/zsh -f > > print "This is $0; FOO = $FOO" > spacely% foo > Function foo; FOO = > This is ./x; FOO = > spacely% FOO=BAR foo > Function foo; FOO = BAR > This is ./x; FOO = BAR > > # Okay so far, but... > > spacely% foo > Function foo; FOO = > This is ./x; FOO = BAR > > FOO should be unset during the last running of ./x. The patch below should fix that. It also removes the first hunk of my previous patch since it is not necessary. Zoltan *** Src/exec.c 1996/07/10 02:34:49 2.56 --- Src/exec.c 1996/07/10 13:32:33 *************** *** 1055,1060 **** --- 1055,1061 ---- if (v->type == PM_SCALAR && (empty(vl) || !nextnode(firstnode(vl)))) { Param pm; char *val; + int allexp; if (empty(vl)) val = ztrdup(""); *************** *** 1064,1074 **** } if (xtr) fprintf(stderr, "%s ", val); ! pm = setsparam(v->name, ztrdup(val)); if (errflag) return; - if (export && !(pm->flags & PM_EXPORTED)) - addenv(v->name, val); zsfree(val); continue; } --- 1065,1079 ---- } if (xtr) fprintf(stderr, "%s ", val); ! if (export) { ! allexp = opts[ALLEXPORT]; ! opts[ALLEXPORT] = 1; ! pm = setsparam(v->name, ztrdup(val)); ! opts[ALLEXPORT] = allexp; ! } else ! pm = setsparam(v->name, ztrdup(val)); if (errflag) return; zsfree(val); continue; } *************** *** 1696,1706 **** paramtab->removenode(paramtab, s); addlinknode(*remove_p, s); addlinknode(*restore_p, pm); - if ((pm->flags & PM_EXPORTED) && pm->env) { - delenv(pm->env); - zsfree(pm->env); - pm->env = NULL; - } } } else { addlinknode(*remove_p, s); --- 1701,1706 ----