From: Paul Wayper <paulway@redhat.com>
To: zsh-workers@zsh.org
Subject: zsh -n does not detect incorrect associative array declaration
Date: Wed, 23 Mar 2016 09:14:47 +1100 [thread overview]
Message-ID: <56F1C3D7.6020800@redhat.com> (raw)
Hi there!
Sourceforge has pointed me to this list as a way to get a bug fixed in zsh.
I've discovered that an incorrect associative array declaration in zsh
isn't detected via 'zsh -n script.zsh', even though it does get flagged
when the script is executed. For example:
$ cat zsh_array.zsh
#!/usr/bin/zsh
typeset -A fn
fn=(foo_key foo_val bar_key bar_val)
printf %s\\n ${fn[foo_key]} ${fn[bar_key]}
$ cat zsh_bad_array.zsh
#!/usr/bin/zsh
typeset -A fn
fn=(foo_key foo_val bar_key)
printf %s\\n $fn[foo_key] $fn[bar_key]
$ zsh -n zsh_array.zsh && echo $?
0
$ zsh zsh_array.zsh
foo_val bar_val
# And yet:
$ zsh -n zsh_bad_array.zsh && echo $?
0
$ zsh zsh_bad_array.zsh
/tmp/zsh_bad_array.zsh:4: bad set of key/value pairs for associative array
This syntax for associative array declaration is the one documented as
correct:
http://zshwiki.org/home/scripting/array
gives the first example of associative array assignment as:
typeset -A buffer
buffer=( key1 val1 key2 val2 )
Ideally what I'd like is for zsh -n to give the same error message on an
incorrect associative array declaration as zsh gives when executing the
script.
Thanks in advance,
Paul
--
Paul Wayper -- Senior Software Maintenance Engineer -- RHCE
Red Hat -- Australia -- Canberra
next reply other threads:[~2016-03-22 22:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 22:14 Paul Wayper [this message]
2016-03-23 0:20 ` Bart Schaefer
2016-03-23 2:28 ` Paul Wayper
2016-03-23 6:40 ` Bart Schaefer
2016-03-23 9:23 ` Peter Stephenson
2016-03-24 2:08 ` Bart Schaefer
2016-03-24 9:46 ` Peter Stephenson
2016-03-24 17:12 ` Bart Schaefer
2016-03-30 6:00 ` Paul Wayper
2016-04-19 13:50 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F1C3D7.6020800@redhat.com \
--to=paulway@redhat.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).