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

zparseopts default associative array



Hi,

if I have this script:

  typeset -A o
  o=(-a AAA -b BBB)
  zparseopts -K -A o a: b:
  print -- ${(kv)o[@]}

and run it such:

  ./script.sh -a foo

I would expect it to output "-a foo -b BBB". But the output is "-a
foo". In the manual the -K option to zparseopts is described as this:

"  -K     With this option, the arrays specified with the -a and -A
options and with the `=array' forms are kept unchanged when none of
the specs for them is used.  This  allows  assignment of default
values to them before calling zparseopts."

Maybe I misunderstood something, but isn't my example the intended use
of -K? Or is the condition "when none of the specs for them is used"
really meant like "if one option is given, all other default values
are emptied"? How would this make sense?

I tried with zsh versions 5.0.2 and 4.3.10.


Sebastian



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