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

Re: Short `if'



"Bart Schaefer" wrote:
> The documentation does explain this:

Maybe this is a bit better.  I think I was partly confused by the fact that
for works happily with no special delimiting in the first group, and partly
the lack of any comment after the particular form of if I was looking at.
I've tried to make it as explicit as possible, because there are bound to
be other equally poor readers.

Index: Doc/Zsh/grammar.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/grammar.yo,v
retrieving revision 1.5
diff -u -r1.5 grammar.yo
--- Doc/Zsh/grammar.yo	2001/06/25 16:07:52	1.5
+++ Doc/Zsh/grammar.yo	2001/07/05 16:59:28
@@ -272,12 +272,17 @@
 Many of zsh's complex commands have alternate forms.  These particular
 versions of complex commands should be considered deprecated and may be
 removed in the future.  The versions in the previous section should be
-preferred instead.  The short versions below only work if var(sublist)
-is of the form `tt({) var(list) tt(})' or if the tt(SHORT_LOOPS)
-option is set.  In this case, the test part of the loop must also be
-suitably delimited, such as by `tt([[ ... ]])' or `tt((( ... )))', else
-the end of the test will not be recognized.
+preferred instead.
 
+The short versions below only work if var(sublist) is of the form `tt({)
+var(list) tt(})' or if the tt(SHORT_LOOPS) option is set.  For the tt(if),
+tt(while) and tt(until) commands, in both these cases the test part of the
+loop must also be suitably delimited, such as by `tt([[ ... ]])' or `tt(((
+... )))', else the end of the test will not be recognized.  For the
+tt(for), tt(repeat), tt(case) and tt(select) commands no such special form
+for the arguments is necessary, but the other condition (the special form
+of var(sublist) or use of the tt(SHORT_LOOPS) option) still applies.
+
 startitem()
 item(tt(if) var(list) tt({) var(list) tt(}) [ tt(elif) var(list) tt({) var(list) tt(}) ] ... [ tt(else {) var(list) tt(}) ])(
 An alternate form of tt(if).  The rules mean that
@@ -296,7 +301,8 @@
 does em(not), since the test is not suitably delimited.
 )
 item(tt(if) var(list) var(sublist))(
-A short form of the alternate `if'.
+A short form of the alternate `if'.  The same limitations on the form of
+var(list) apply as for the previous form.
 )
 item(tt(for) var(name) ... tt(LPAR()) var(word) ... tt(RPAR()) var(sublist))(
 A short form of tt(for).
@@ -312,10 +318,12 @@
 Another form of tt(for).
 )
 item(tt(while) var(list) tt({) var(list) tt(}))(
-An alternative form of tt(while).
+An alternative form of tt(while).  Note the limitations on the form of
+var(list) mentioned above.
 )
 item(tt(until) var(list) tt({) var(list) tt(}))(
-An alternative form of tt(until).
+An alternative form of tt(until).  Note the limitations on the form of
+var(list) mentioned above.
 )
 item(tt(repeat) var(word) var(sublist))(
 This is a short form of tt(repeat).

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


**********************************************************************
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