zsh-workers
 help / color / mirror / code / Atom feed
* Is this intentional behavior of typeset -g ?
@ 2024-02-16 20:09 Bart Schaefer
  2024-02-17  6:29 ` Regression of typeset output with "private" Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2024-02-16 20:09 UTC (permalink / raw)
  To: Zsh hackers list

Just noticed that this:
  typeset -g foo=global
  local foo=local
changes the scope of "foo" from global** to local, but this:
  local foo=local
  typeset -g foo=global
does NOT assign to "foo" in the global** scope, it just continues to
apply to the local.

** "global" meaning any surrounding dynamic scope possibly up to the top level.

That is, the -g option starts "searching" at the current scope and
stops as soon as it encounters a declaration (even if the name is
unset), rather than (as one might think) starting one level above the
current.  Note prior mention of how ungainly it is to insert new
parameters at a surrounding scope, so I'm pretty sure this has always
been this way.

If this is legitimately the expected behavior (and it seems to be the
historic and possibly necessary behavior) there may be an easy
workaround for the "typeset -n" issue that was reported in
workers/52530 (or maybe this doesn't help at all, I haven't worked
through details yet).

Tangentially, I think there's a regression with "private":

() {
  zmodload zsh/param/private
  private foo=local
  typeset -p foo
}

That now prints nothing, whereas in e.g. 5.7 it would say
  typeset foo=local
which isn't precisely accurate either.


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

end of thread, other threads:[~2024-02-20  4:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16 20:09 Is this intentional behavior of typeset -g ? Bart Schaefer
2024-02-17  6:29 ` Regression of typeset output with "private" Bart Schaefer
2024-02-18 19:35   ` Bart Schaefer
2024-02-20  4:54     ` [PATCH] (take 2) Local specials and " Bart Schaefer

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).