Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zparseopts default associative array
- X-seq: zsh-users 18436
- From: Sebastian Stark <seb.stark@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: zparseopts default associative array
- Date: Thu, 13 Feb 2014 08:17:58 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7qNAmPFj+iGJ9JiW2n+HXaV6I/dAbHPExo9NnjkuO7E=; b=OI8UP6DB9cAGMYOxVkVRbdp8DZlL0wP/OiP6PIteKYgYnwIQbtWK6taVEySM9Z/qiH J3vjbo9cRa4FG1Voulg1ALyL3tRKzKg84rojzG8ebTJtEyUvOKXSG799+IUhQgNII1/7 PrvzqESgE2BnztxUB8cUnG++I+I2I3kbX8/adWDsYsoTUCQkfHPiRVDjlNNigwqHQ87a Ch6fb9+H3m11Oy5S1Ub0sRB4tNFfVqNT8Yq1fr18FCPfNFzAtFpJD3KJ8RNGzvIooWON SSjJHayX/RMb3exNK+sv1HrM4F6xf3Vk8QeJ5VqjZyShitP7w0sTvw9rOZfJV6jlpwRx UV4w==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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