On Wed, 27 Feb 2008 09:35:40 -0500
Clint Adams <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to