(zsh.info.gz) Alternate Forms For Complex Commands
Info Catalog
(zsh.info.gz) Complex Commands
(zsh.info.gz) Shell Grammar
(zsh.info.gz) Reserved Words
6.4 Alternate Forms For Complex Commands
========================================
Many of zsh's complex commands have alternate forms. These are
non-standard and are likely not to be obvious even to seasoned shell
programmers; they should not be used anywhere that portability of shell
code is a concern.
The short versions below only work if SUBLIST is of the form '{ LIST }'
or if the SHORT_LOOPS option is set. For the if, while and until
commands, in both these cases the test part of the loop must also be
suitably delimited, such as by '[[ ... ]]' or '(( ... ))', else the end
of the test will not be recognized. For the for, repeat, case and
select commands no such special form for the arguments is necessary, but
the other condition (the special form of SUBLIST or use of the
SHORT_LOOPS option) still applies.
if LIST { LIST } [ elif LIST { LIST } ] ... [ else { LIST } ]
An alternate form of if. The rules mean that
if [[ -o ignorebraces ]] {
print yes
}
works, but
if true { # Does not work!
print yes
}
does _not_, since the test is not suitably delimited.
if LIST SUBLIST
A short form of the alternate 'if'. The same limitations on the
form of LIST apply as for the previous form.
for NAME ... ( WORD ... ) SUBLIST
A short form of for.
for NAME ... [ in WORD ... ] TERM SUBLIST
where TERM is at least one newline or ;. Another short form of
for.
for (( [EXPR1] ; [EXPR2] ; [EXPR3] )) SUBLIST
A short form of the arithmetic for command.
foreach NAME ... ( WORD ... ) LIST end
Another form of for.
while LIST { LIST }
An alternative form of while. Note the limitations on the form of
LIST mentioned above.
until LIST { LIST }
An alternative form of until. Note the limitations on the form of
LIST mentioned above.
repeat WORD SUBLIST
This is a short form of repeat.
case WORD { [ [(] PATTERN [ | PATTERN ] ... ) LIST (;;|;&|;|) ] ... }
An alternative form of case.
select NAME [ in WORD TERM ] SUBLIST
where TERM is at least one newline or ;. A short form of select.
Info Catalog
(zsh.info.gz) Complex Commands
(zsh.info.gz) Shell Grammar
(zsh.info.gz) Reserved Words
automatically generated by
info2html