Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug Report: Env Vars and shell functions
- X-seq: zsh-workers 1598
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: acs@xxxxxxxxxxxxx
- Subject: Re: Bug Report: Env Vars and shell functions
- Date: Wed, 10 Jul 1996 15:45:03 +0200 (MET DST)
- Cc: pws@xxxxxx, zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: <199607101219.IAA25984@xxxxxxxxxxxxxxxxxxxxxxxx> 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
> 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 ----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author