From: ZyX <zyx.vim@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: zsh -n doesn't grok associate array indexes?
Date: Mon, 10 Jan 2011 20:48:19 +0300 [thread overview]
Message-ID: <201101102048.19802@-zyx> (raw)
In-Reply-To: <AANLkTinS48=Jtes47ryS1aSdX4+o4z3rSO45G6mhSTAg@mail.gmail.com>
[-- Attachment #1: Type: Text/Plain, Size: 1968 bytes --]
Reply to message «zsh -n doesn't grok associate array indexes?»,
sent 20:18:09 10 January 2011, Monday
by Rocky Bernstein:
Confirmed:
zsh << EOF
emulate -LR zsh
typeset -A hash
hash['display']=5
echo ${hash['display']}
EOF
echoes 5 as expected, but «zsh -n» echoes the same error.
% zsh --version
zsh 4.3.10 (x86_64-pc-linux-gnu)
By the way, if I replace «'display'» with «display» (which is correct because
zsh does not unquote subscripts, you can check it by using «echo ${(kv)hash}») I
I get correct value without «-n» and «zsh: hash: assignment to invalid subscript
range» with «-n».
By the way, I can't find description of «NO_EXEC» option in «man zshoptions».
Original message:
> I tried zsh -n to see how good a tool it might be for lint checking.
> Overall it works very well.
>
> However I ran into a problem when using a string associative array index.
> Here's a sample run:
>
> $ cat /tmp/zsh-bug.sh
>
> > typeset -A hash
> > hash['display']=5
> > echo ${hash['display']}
> > $ zsh /tmp/zsh-bug.sh
> > 5
> > $ zsh -n /tmp/zsh-bug.sh
> > /tmp/zsh-bug.sh:2: bad math expression: operand expected at `'display''
> > /tmp/zsh-bug.sh:3: bad math expression: operand expected at `'display''
> > $ zsh --version
> > zsh 4.3.10 (i686-pc-linux-gnu)
> > $
>
> By the way, I also tried ksh -n from version 93u- 2010-09-22. It also
> catches basic syntax errors such as with
> complex statements (if, while, case, for) but offers a number of lint- like
> suggestions such as to improve speed and and allow for better
> ksh conformance. Out of 57 or so files I tried in the zshdb
> distribution, there were about 5 errors which I don't think anythingn could
> be done about, i.e. legitimate differences between zsh and ksh. However
> there were many warnings for performance improvements, removing deprecated
> constructs and better ksh conformance.
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2011-01-10 17:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-10 17:18 Rocky Bernstein
2011-01-10 17:48 ` ZyX [this message]
2011-01-10 18:20 ` Peter Stephenson
2011-01-10 19:32 ` Rocky Bernstein
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=201101102048.19802@-zyx \
--to=zyx.vim@gmail.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).