Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ${a[(i)pattern]} if a=()



On Mar 16, 10:20am, Bart Schaefer wrote:
}
} } $ zsh -f -c 'a=(); echo ${a[(i)a]}'
} } 0
} 
} Hmm ... it seems it has always returned zero when the array is empty.
} It would seem to make more sense for it to return 1, but I'm worried
} there are other unforseen consequences.

The patch is trivial and all tests still pass.  Thoughts?

Index: Src/params.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/params.c,v
retrieving revision 1.40
diff -c -r1.40 params.c
--- ../zsh-forge/current/Src/params.c	11 Jan 2008 01:18:07 -0000
+++ Src/params.c	16 Mar 2008 17:52:10 -0000
@@ -1317,7 +1317,7 @@
 	    } else
 		ta = getarrvalue(v);
 	    if (!ta || !*ta)
-		return 0;
+		return !down;
 	    len = arrlen(ta);
 	    if (beg < 0)
 		beg += len;



Messages sorted by: Reverse Date, Date, Thread, Author