GNU Info

Info Node: (zsh.info)Alternate Forms For Complex Commands

(zsh.info)Alternate Forms For Complex Commands


Next: Reserved Words Prev: Complex Commands Up: Shell Grammar
Enter node , (file) or (file)node

Alternate Forms For Complex Commands
====================================

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


automatically generated by info2www version 1.2.2.9