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

Re: uninvited members of associative array




On 2022-12-16 02:05, Dominik Vogt wrote:

The issue is not solved.  You still have something that adds the
bogus values before the reinitialisation.  Whether this has some
adverse effects depends on the scripts.  (Sample script attached).
Basically you probably do ~ this:

True Dominik, it's not solved, I should rather say I can put it on ice for a while while I attend to another issue more pressing. I will get back to it and I'll let you all know what I found.  It is probably exactly as yourself and Bart suspect.  I will catch it.

Roman:

I just want to point out that in general you need to quote the array
expansion here or you'll get surprises if the array has empty keys
and/or values. Consider this:

    typeset -A main=(
      foo '1'
      bar '2'
      baz ''
      qux ''
    )

    printf  '%-4s = %s\n' ${(kv)main}

And the output:

    foo  = 1
    baz  = bar
    2    = qux

... this is exactly the sort of thing I was talking to Lawrence about -- not really a hard error, just some printout issue.  I'll pursue that.  I (think I) understand that AAs are very fragile creatures and as you demonstrate, easily confused.  I'll bag it.









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