Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix crash on unset-through-nameref
On Wed, Mar 6, 2024 at 10:21 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> 2024-03-05 15:16:25 -0800, Bart Schaefer:
> > why do you never use -fc to prevent dotfiles from being read?
>
> I hadn't realised -f also skipped ~/.zshenv
>
> Should we also use
>
> #! /bin/zsh -f-
>
> shebangs in scripts?
I usually assume scripts want ~/.zshenv for PATH values etc. As usual
you should do what makes sense for the specific script.
> My point is that if it means the:
>
> assign() {
> typeset -n var=$1
> local value=$2
> var=$value
> }
>
> doesn't work for
>
> assign var value
> or
> assign value something
No, but as of the last patch it works for both of those cases if you use
assign() {
typeset -g $1
typeset -nu var=$1
local value=$2
var=$value
}
You don't have to futz with local parameter names, but you do have to
make sure that the "typeset -g" declaration has a compatible type with
the "var=$value" at the end.
The "typeset -nu" declaration can't know what you're going to assign
later, so it doesn't make sense for it to try to magically perform the
"typeset -g". We don't have a "typeless and waiting for assignment"
parameter type.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author