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

Re: BUG: Initializations of named references with an empty string should trigger an error



On Thu, May 22, 2025 at 1:32 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> $ typeset -n ref1=""
> zsh: invalid variable name:
> $ typeset ref2
> $ typeset -n ref2
> $ typeset -p ref2
> typeset -n ref2=''
>
> Interestingly converting a scalar initialized with an empty string triggers the invalid name error:
>
> $ typeset ref3=""
> $ typeset -n ref3
> zsh: invalid variable name:

This reminds me of something I noticed earlier when I was looking at
the current manpage:
       An empty reference such as one of

              typeset -n pname
              typeset -n pname=
              typeset -n pname=""

This is possibly a bit confusing since it implies that the last two
commands are not identical, which they are. If there are no complaints
I'll just remove the third line. (Other identical commands would be
typeset"" -n"" pname= and typese"t" -"n" pname"=" for example, which I
think everyone will agree would be silly to list.)

-- 
Mikael Magnusson




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