Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Up-scope named references, vs. ksh



2024-03-01 15:28:58 -0800, Bart Schaefer:
> On Fri, Mar 1, 2024 at 10:22 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> >
> > $ ./Src/zsh -c 'f() { typeset -n ref=$1; unset ref; local var=2; ref=3; }; typeset -A var; f var; echo $var'
> > <empty>
> 
> That's an actual bug, regardless of the rest of this discussion.
[...]

If that one can be fixed then why can't the main one, namely:

assign() {
  typeset -n var=$1
  typeset    value=$2
  var=$value
}
assign value x
echo $value

(or assign var x returning an error)

be fixed the same way, that is typeset -n ref=var doing the
equivalent of assigning var and unsetting afterwards if it is
previously not found? 

-- 
Stephane




Messages sorted by: Reverse Date, Date, Thread, Author