Next: Reserved Words, Previous: Complex Commands, Up: Shell Grammar [Contents][Index]
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.
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.
A short form of the alternate if. The same limitations on the form of list apply as for the previous form.
A short form of for.
where term is at least one newline or ;. Another short form of for.
A short form of the arithmetic for command.
Another form of for.
An alternative form of while. Note the limitations on the form of list mentioned above.
An alternative form of until. Note the limitations on the form of list mentioned above.
This is a short form of repeat.
An alternative form of case.
where term is at least one newline or ;. A short form of select.
This is a short form of function.
Next: Reserved Words, Previous: Complex Commands, Up: Shell Grammar [Contents][Index]