Copyright (C) 2000-2012 |
GNU Info (zsh.info)Complex CommandsComplex Commands ================ A _complex command_ in zsh is one of the following: if LIST then LIST [ elif LIST then LIST ] ... [ else LIST ] fi The if LIST is executed, and if it returns a zero exit status, the then LIST is executed. Otherwise, the elif LIST is executed and if its value is zero, the then LIST is executed. If each elif LIST returns nonzero, the else LIST is executed. for NAME [ in WORD ... TERM ] do LIST done where TERM is at least one newline or ;. Expand the list of WORDs, and set the parameter NAME to each of them in turn, executing LIST each time. If the in WORD is omitted, use the positional parameters instead of the WORDs. for (( [EXPR1] ; [EXPR2] ; [EXPR3] )) do LIST done The arithmetic expression EXPR1 is evaluated first (see Note: Arithmetic Evaluation). The arithmetic expression EXPR2 is repeatedly evaluated until it evaluates to zero and when non-zero, LIST is executed and the arithmetic expression EXPR3 evaluated. If any expression is omitted, then it behaves as if it evaluated to 1. while LIST do LIST done Execute the do LIST as long as the while LIST returns a zero exit status. until LIST do LIST done Execute the do LIST as long as until LIST returns a nonzero exit status. repeat WORD do LIST done WORD is expanded and treated as an arithmetic expression, which must evaluate to a number N. LIST is then executed N times. case WORD in [ [(] PATTERN [ | PATTERN ] ... ) LIST (;;|;&) ] ... esac Execute the LIST associated with the first PATTERN that matches WORD, if any. The form of the patterns is the same as that used for filename generation. See Note: Filename Generation. If the LIST that is executed is terminated with ;& rather than ;;, the following list is also executed. This continues until either a list is terminated with ;; or the esac is reached. select NAME [ in WORD ... TERM ] do LIST done where TERM is one or more newline or ; to terminate the WORDs. Print the set of WORDs, each preceded by a number. If the in WORD is omitted, use the positional parameters. The PROMPT3 prompt is printed and a line is read from the line editor if the shell is interactive and that is active, or else standard input. If this line consists of the number of one of the listed WORDs, then the parameter NAME is set to the WORD corresponding to this number. If this line is empty, the selection list is printed again. Otherwise, the value of the parameter NAME is set to null. The contents of the line read from standard input is saved in the parameter REPLY. LIST is executed for each selection until a break or end-of-file is encountered. ( LIST ) Execute LIST in a subshell. Traps set by the trap builtin are reset to their default values while executing LIST. { LIST } Execute LIST. function WORD ... [ () ] [ TERM ] { LIST } WORD ... () [ TERM ] { LIST } WORD ... () [ TERM ] COMMAND where TERM is one or more newline or ;. Define a function which is referenced by any one of WORD. Normally, only one WORD is provided; multiple WORDs are usually only useful for setting traps. The body of the function is the LIST between the { and }. See Note: Functions. If the option SH_GLOB is set for compatibility with other shells, then whitespace may appear between between the left and right parentheses when there is a single WORD; otherwise, the parentheses will be treated as forming a globbing pattern in that case. time [ PIPELINE ] The PIPELINE is executed, and timing statistics are reported on the standard error in the form specified by the TIMEFMT parameter. If PIPELINE is omitted, print statistics about the shell process and its children. [[ EXP ]] Evaluates the conditional expression EXP and return a zero exit status if it is true. See Note: Conditional Expressions for a description of EXP. automatically generated by info2www version 1.2.2.9 |