zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Roman Perepelitsa <roman.perepelitsa@gmail.com>,
	Pier Paolo Grassi <pierpaolog@gmail.com>,
	 Zsh Users <zsh-users@zsh.org>
Subject: Re: A way to untie -T vars?
Date: Mon, 23 Jan 2023 19:42:02 +0100	[thread overview]
Message-ID: <CAHYJk3Qv9tivoCAZJh4LcGQZ0cQ9WhCHcAt-7iMuPY_QFMvWEQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7bzka=NBZ1SGRt7Fj65KuC3mmH99E8uyCn=Ff=uFaM58w@mail.gmail.com>

On 1/23/23, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Mon, Jan 23, 2023 at 1:47 AM Roman Perepelitsa
> <roman.perepelitsa@gmail.com> wrote:
>>
>> Here foo is array-local-tag-tied-unique-hide-hideval. I believe it can
>> be untied and become array-local-tag-unique-hide-hideval (only "tied"
>> is gone).
>
> Hm.
>
> Another interesting note, "typeset -x" implies "-g" but "local -x" does
> not.

There's no way it could imply it, since local -g doesn't accept -g, so
you would have to argue why typeset -x should not imply it (and do it
like 30 years ago) :).

Checked the manpage and it says export is equivalent to typeset -gx,
which is true, but we could save a byte by removing that g.

Also local says this:
  Same  as  typeset,  except that the options -g, and -f are not permitted.  In
  this case the -x option does not force the use of -g, i.e. exported variables
  will be local to functions.

which does not seem to be true; typeset -x does not force -g, it is
implied by default but you can use +g to disable it again:

% bar=outside; () { typeset -x +g bar=baz; env | grep bar=baz }; echo $bar
bar=baz
outside

without the +g, the second line output is "baz" (obviously).

The entry for typeset itself correctly states:
  If the option GLOBAL_EXPORT is set, this implies the option -g,
unless  +g is also explicitly given; in other words the parameter is
not made local to the enclosing function.  This is for  compatibility
with previous versions of zsh.

Not sure if it's worth clarifying the point under "local"?

Also for maximum confusion, GLOBAL_EXPORT doesn't affect the behavior
of "export", that always forces (not implies) both -x and -g:
% export +x foo
export: bad option: +x
% export +g foo
export: bad option: +g
but with GLOBAL_EXPORT unset, my example above prints "outside" on the
second line even without the +g.

-- 
Mikael Magnusson


  reply	other threads:[~2023-01-23 18:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 16:37 Sebastian Gniazdowski
2023-01-21 16:55 ` Bart Schaefer
2023-01-21 17:11   ` Bart Schaefer
2023-01-21 18:52     ` Bart Schaefer
2023-01-21 19:15       ` Roman Perepelitsa
2023-01-22  9:34         ` Pier Paolo Grassi
2023-01-22  9:58           ` Roman Perepelitsa
2023-01-23  2:14             ` Bart Schaefer
2023-01-23  9:47               ` Roman Perepelitsa
2023-01-23 18:27                 ` Bart Schaefer
2023-01-23 18:42                   ` Mikael Magnusson [this message]
2023-01-23 18:43                     ` Mikael Magnusson
2023-01-23 19:12                     ` Bart Schaefer
2023-01-24  5:45                   ` Bart Schaefer
2023-01-24  9:56                     ` Roman Perepelitsa
2023-01-24 16:42                       ` Bart Schaefer
2023-01-24 16:45                         ` Peter Stephenson
2023-01-24 17:40                           ` Bart Schaefer
2023-01-24 17:54                             ` Roman Perepelitsa
2023-01-24 22:54                               ` Bart Schaefer
2023-01-25 14:41                                 ` Roman Perepelitsa
2023-01-25 22:39                                   ` Bart Schaefer
2023-01-25 23:48                                     ` Bart Schaefer
2023-01-26  2:34                                       ` Bart Schaefer
2023-01-21 17:15   ` Roman Perepelitsa
2023-01-21 17:23     ` Bart Schaefer
2023-01-21 17:31 ` Bart Schaefer
2023-01-21 17:48   ` Roman Perepelitsa
2023-01-21 17:50     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3Qv9tivoCAZJh4LcGQZ0cQ9WhCHcAt-7iMuPY_QFMvWEQ@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=pierpaolog@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).