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

Re: [BUG] ksh_zero_subscript messes with associative arrays



> On 26/07/2022 18:10 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Tue, Jul 26, 2022 at 10:00 AM Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Something is tickling my brain to the effect that this was left this
> > way for bug-compatibility with some version of (perhaps pd) ksh ...
> 
> More of this comes back to me ... I think the situation is/was this:
> 
> hash=( [Y]=why [0]=zero )
> echo $hash
> zero
> 
> That is, reference to the entire hash without subscript returns a
> reference to the element with key "0", just as reference to an array
> without subscript returns the 0th element.
> 
> So there's probably not after all a connection to other unset
> elements, but I think PWS's patch will alter the above behavior as
> well?

Yes, I remember this oddity now.

However, "echo $hash" with only kshzerosubscript (not ksharrays ---
with which it would be pointless) echoes the full hash, so no
change here.  But I suspect there are other cases it does affect.

Do we actually care?  Could we just document it?  Or is the effect
so small anyway it's best to leave it the way it is and note the
oddities with hashes?

pws




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