2013-10-15 15:17:36 +00:00
|
|
|
foreach
|
|
|
|
-------
|
|
|
|
|
|
|
|
Evaluate a group of commands for each value in a list.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
foreach(loop_var arg1 arg2 ...)
|
|
|
|
COMMAND1(ARGS ...)
|
|
|
|
COMMAND2(ARGS ...)
|
|
|
|
...
|
|
|
|
endforeach(loop_var)
|
|
|
|
|
|
|
|
All commands between foreach and the matching endforeach are recorded
|
|
|
|
without being invoked. Once the endforeach is evaluated, the recorded
|
|
|
|
list of commands is invoked once for each argument listed in the
|
|
|
|
original foreach command. Before each iteration of the loop
|
2015-06-04 21:51:22 +00:00
|
|
|
``${loop_var}`` will be set as a variable with the current value in the
|
2013-10-15 15:17:36 +00:00
|
|
|
list.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
foreach(loop_var RANGE total)
|
|
|
|
foreach(loop_var RANGE start stop [step])
|
|
|
|
|
|
|
|
Foreach can also iterate over a generated range of numbers. There are
|
|
|
|
three types of this iteration:
|
|
|
|
|
|
|
|
* When specifying single number, the range will have elements 0 to
|
2013-09-12 15:41:36 +00:00
|
|
|
"total".
|
2013-10-15 15:17:36 +00:00
|
|
|
|
|
|
|
* When specifying two numbers, the range will have elements from the
|
2013-09-12 15:41:36 +00:00
|
|
|
first number to the second number.
|
2013-10-15 15:17:36 +00:00
|
|
|
|
|
|
|
* The third optional number is the increment used to iterate from the
|
2013-09-12 15:41:36 +00:00
|
|
|
first number to the second number.
|
2013-10-15 15:17:36 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
foreach(loop_var IN [LISTS [list1 [...]]]
|
|
|
|
[ITEMS [item1 [...]]])
|
|
|
|
|
2015-06-04 21:51:22 +00:00
|
|
|
Iterates over a precise list of items. The ``LISTS`` option names
|
2013-10-15 15:17:36 +00:00
|
|
|
list-valued variables to be traversed, including empty elements (an
|
2013-11-18 13:30:52 +00:00
|
|
|
empty string is a zero-length list). (Note macro
|
2015-06-04 21:51:22 +00:00
|
|
|
arguments are not variables.) The ``ITEMS`` option ends argument
|
2013-10-15 15:17:36 +00:00
|
|
|
parsing and includes all arguments following it in the iteration.
|