Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to have function local variable but must behave just a simple one
- X-seq: zsh-users 29205
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Budi <budikusasi@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: How to have function local variable but must behave just a simple one
- Date: Sat, 26 Aug 2023 13:26:21 -0700
- Archived-at: <https://zsh.org/users/29205>
- In-reply-to: <CAN=4vMr9UjvPAJNRW8i6xviCwy-aLTb+oKoO3Y+Y-wnYzGLc7w@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAH0GyZAfvds3Ztby301R+3dp0WuFWNn=0bLAQ+h5Stvp4z9tOQ@mail.gmail.com> <CAN=4vMr9UjvPAJNRW8i6xviCwy-aLTb+oKoO3Y+Y-wnYzGLc7w@mail.gmail.com>
On Sat, Aug 26, 2023 at 12:34 AM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> Zsh doesn't have the equivalent. You'll have to use a global parameter.
More generically speaking, shells typically use dynamic scoping rather
than lexical scoping, which means a variable only persists until the
scope where it is declared finishes, and while it persists it is
available to all deeper scopes. The zsh/param/private module changes
some of the availability rules, but nothing changes the persistence.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author