Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: extra loop tests
- X-seq: zsh-workers 18389
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: extra loop tests
- Date: Wed, 26 Mar 2003 14:16:41 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Tests for the enhanced `for' syntax as well as `select' which is now
testable (according to `cvs annotate', I fixed it all of three years ago,
except as we know it was broken for a large fraction of that time
because of the for-loop change. A year is a short time in zsh
development).
Extra tests gratefully received, as Felix reminded us, particularly for
interactive stuff (zle, completion) which I will not be attempting
myself.
When we finally get the multiple defined limits problem fixed, I will
produce a test version of 4.1.1. If tests continue to trickle in, so
much the better.
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.6
diff -u -r1.6 A01grammar.ztst
--- Test/A01grammar.ztst 17 Sep 2002 10:42:20 -0000 1.6
+++ Test/A01grammar.ztst 26 Mar 2003 14:07:06 -0000
@@ -136,6 +136,29 @@
>1
>2
+ for keyvar valvar in key1 val1 key2 val2; do
+ print key=$keyvar val=$valvar
+ done
+0:enhanced `for' syntax with two loop variables
+>key=key1 val=val1
+>key=key2 val=val2
+
+ for keyvar valvar stuffvar in keyA valA stuffA keyB valB stuffB; do
+ print key=$keyvar val=$valvar stuff=$stuffvar
+ done
+0:enhanced `for' syntax with three loop variables
+>key=keyA val=valA stuff=stuffA
+>key=keyB val=valB stuff=stuffB
+
+ for in in in in in stop; do
+ print in=$in
+ done
+0:compatibility of enhanced `for' syntax with standard syntax
+>in=in
+>in=in
+>in=in
+>in=stop
+
name=0
while (( name < 3 )); do
print $name
@@ -208,18 +231,17 @@
>2
>3
-## This doesn't work, because zsh tries to read from the terminal
-## even in a non-interactive shell. The manual implies it always reads
-## from stdin, even in an interactive shell.
-# PS3="input> "
-# select name in one two three; do
-# print $name
-# done
-#0:`select' loop
-#<2
-#>1) one 2) two 3) three
-#>input>
-#>two
+## Select now reads from stdin if the shell is not interactive.
+## Its own output goes to stderr.
+ PS3="input> "
+ select name in one two three; do
+ print $name
+ done
+0:`select' loop
+<2
+?1) one 2) two 3) three
+?input> input>
+>two
function name1 name2 () { print This is $0; }
name2
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author