zsh-workers
 help / color / mirror / code / Atom feed
* Anybody objects to the following change in createparamtable()?
@ 2000-07-27  8:12 Andrej Borsenkow
  2000-07-27  8:50 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Andrej Borsenkow @ 2000-07-27  8:12 UTC (permalink / raw)
  To: ZSH workers mailing list

In createparamtable() (copy environment loop):

  if ((!(pm = (Param) paramtab->getnode(paramtab, iname)) ||
       !(pm->flags & PM_DONTIMPORT) && !(pm->flags & PM_EXPORTED)) &&
      (pm = setsparam(iname, metafy(str + 1, -1, META_DUP)))) {
      *str = '=';
      pm->flags |= PM_EXPORTED;
        ....

The reason is, if we have duplicated environment entries, last one wins and
call to setsparam() will try to modify environment in the middle of traversing
it I'd prefer, if check for PM_EXPORTED comes first - if parameter is already
exported, just skip any environment with the same name.

At this point the only exported parameters are the ones resulted from
importing environment so it should be safe.

-andrej

Have a nice DOS!
B >>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Anybody objects to the following change in createparamtable()?
  2000-07-27  8:12 Anybody objects to the following change in createparamtable()? Andrej Borsenkow
@ 2000-07-27  8:50 ` Bart Schaefer
  2000-07-27  9:13   ` Andrej Borsenkow
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2000-07-27  8:50 UTC (permalink / raw)
  To: ZSH workers mailing list

On Jul 27, 12:12pm, Andrej Borsenkow wrote:
} Subject: Anybody objects to the following change in createparamtable()?
}
} In createparamtable() (copy environment loop):
} 
} ššif ((!(pm = (Param) paramtab->getnode(paramtab, iname)) ||

Where'd those '\232' characters come from?  Please don't let any of those
creep into the actual source code ...

} The reason is, if we have duplicated environment entries, last one
} wins and call to setsparam() will try to modify environment in the
} middle of traversing it.  I'd prefer, if check for PM_EXPORTED comes
} first - if parameter is already exported, just skip any environment
} with the same name.

This is probably OK.  Take a look at this (ignore zsh vs. tcsh hostname
confusion):

zagzig[267] tcsh
[schaefer@candle]$ setenv FOO FOO
[schaefer@candle]$ echo $FOO
FOO
[schaefer@candle]$ setenv FOO=BAR BAZ
[schaefer@candle]$ echo $FOO
FOO
[schaefer@candle]$ printenv | grep FOO
FOO=FOO
FOO=BAR=BAZ
[schaefer@candle]$ zsh -f
zagzig% echo $ZSH_VERSION $FOO
3.0.8 FOO
zagzig% printenv | grep FOO
FOO=FOO
zagzig% 
[schaefer@candle]$ zsh-3.1.9-dev-3 -f
zagzig% echo $ZSH_VERSION $FOO
3.1.9-dev-3 BAR=BAZ                            <-- Last appears to win but
zagzig% printenv | grep FOO
FOO=FOO                                        <-- does not match environ!
zagzig% 
[schaefer@candle]$ bash
[schaefer@zagzig current]$ echo $FOO
BAR=BAZ
[schaefer@zagzig current]$ printenv | grep FOO
FOO=BAR=BAZ

So we have zsh-3.0.8 where the first one wins consistently, and bash
where the last one wins consistently, and zsh-3.1.9-dev-3 which does
not behave consistently at all.

} At this point the only exported parameters are the ones resulted from
} importing environment so it should be safe.

This all depends on your definition of "safe" ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Anybody objects to the following change in createparamtable()?
  2000-07-27  8:50 ` Bart Schaefer
@ 2000-07-27  9:13   ` Andrej Borsenkow
  0 siblings, 0 replies; 3+ messages in thread
From: Andrej Borsenkow @ 2000-07-27  9:13 UTC (permalink / raw)
  To: Bart Schaefer, ZSH workers mailing list

> } ššif ((!(pm = (Param) paramtab->getnode(paramtab, iname)) ||
>
> Where'd those '\232' characters come from?  Please don't let any of those
> creep into the actual source code ...
>

Copy'n'paste out of Motif GVim under Exceed ... ough :-) There is something
fishy with Vim; I noted it already but am too lazy to look into ...

> [schaefer@candle]$ zsh-3.1.9-dev-3 -f
> zagzig% echo $ZSH_VERSION $FOO
> 3.1.9-dev-3 BAR=BAZ                            <-- Last appears to win but
> zagzig% printenv | grep FOO
> FOO=FOO                                        <-- does not match environ!

Yes, I know. Call to setsparam() finally calls replenv() that searches old
environment, finds nothing and does nothing. So, newly built env table gets
the first value found, but parameter itself the last one.

>
> This all depends on your definition of "safe" ...
>

I just meant, that it won't prevent importing value of some parameter already
exported by Zsh on it's own.

-andrej


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-07-27  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-27  8:12 Anybody objects to the following change in createparamtable()? Andrej Borsenkow
2000-07-27  8:50 ` Bart Schaefer
2000-07-27  9:13   ` Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).