From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Cc: 466655@bugs.debian.org
Subject: Re: Bug#466655: the expression {x=(); echo ${+x[(r)blah]}} changes meaning between 4.3.2 and current version
Date: Wed, 27 Feb 2008 15:29:57 +0000 [thread overview]
Message-ID: <20080227152957.4413579d@news01> (raw)
In-Reply-To: <20080227143540.GB8314@scowler.net>
On Wed, 27 Feb 2008 09:35:40 -0500
Clint Adams <schizo@debian.org> wrote:
> On Wed, Feb 20, 2008 at 07:09:05AM +0000, Frederik Eaton wrote:
> > Hello, one of my scripts has broken because of the following change:
> >
> > $ zsh --version
> > zsh 4.3.2 (i686-pc-linux-gnu)
> > $ x=(); echo ${+x[(r)blah]}
> > 0
> >
> > $ zsh --version
> > zsh 4.3.5 (i686-pc-linux-gnu)
> > $ x=(); echo ${+x[(r)blah]}
> > 1
> >
> > Is the behaviour of zsh's parameter expansion supposed to be stable?
>
> I think this is related to 23273*
No, this is unexpected fallout from the changes to make zero subscripts
behave in a more rational fashion, 23562. I hadn't even remembered this
form worked with subscripts, but the the manual certainly suggests it
should (and it's definitely useful). I've added a test that should keep it
working.
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.82
diff -u -r1.82 subst.c
--- Src/subst.c 16 Dec 2007 14:05:16 -0000 1.82
+++ Src/subst.c 27 Feb 2008 15:28:41 -0000
@@ -1915,7 +1915,8 @@
hkeys|hvals|
(arrasg ? SCANPM_ASSIGNING : 0)|
(qt ? SCANPM_DQUOTED : 0))) ||
- (v->pm && (v->pm->node.flags & PM_UNSET)))
+ (v->pm && (v->pm->node.flags & PM_UNSET)) ||
+ (v->flags & VALFLAG_EMPTY))
vunset = 1;
if (wantt) {
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.29
diff -u -r1.29 D04parameter.ztst
--- Test/D04parameter.ztst 30 Oct 2007 14:01:35 -0000 1.29
+++ Test/D04parameter.ztst 27 Feb 2008 15:28:41 -0000
@@ -52,6 +52,14 @@
0:$+...
>1 1 0 0
+ x=()
+ print ${+x} ${+x[1]} ${+x[(r)foo]} ${+x[(r)bar]}
+ x=(foo)
+ print ${+x} ${+x[1]} ${+x[(r)foo]} ${+x[(r)bar]}
+0:$+... with arrays
+>1 0 0 0
+>1 1 1 0
+
set1=set1v
null1=
print ${set1:-set1d} ${set1-set2d} ${null1:-null1d} ${null1-null2d} x
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
next prev parent reply other threads:[~2008-02-27 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080220070905.7276.65390.reportbug@localhost.localdomain>
2008-02-27 14:35 ` Clint Adams
2008-02-27 15:29 ` Peter Stephenson [this message]
2008-02-27 16:50 ` Frederik Eaton
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=20080227152957.4413579d@news01 \
--to=pws@csr.com \
--cc=466655@bugs.debian.org \
--cc=zsh-workers@sunsite.dk \
/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).