Files
u-boot-krane/doc/usage/cmd/for.rst
T
Marek VasutandHeinrich Schuchardt dc3765ede5 doc: Switch from setenv to env set
The "env" command is the recommended environment management command,
its "set" subcommand is the equivalent replacement for legacy "setenv"
command. Update the documentation to use the contemporary "env set"
command instead of legacy "setenv" command.

Note that the "setenv" command is unlikely to be removed from U-Boot
in the near future due to it being integral part of the command line
ABI.

Implemented using:
$ sed -i 's@\<setenv\>@env set@g' $(git grep -li '\<setenv\>' doc/) README

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2026-07-27 18:50:27 +02:00

69 lines
1.3 KiB
ReStructuredText

.. index::
single: for (command)
for command
===========
Synopsis
--------
::
for <variable> in <items>; do <commands>; done
Description
-----------
The for command is used to loop over a list of values and execute a series of
commands for each of these.
The counter variable of the loop is a shell variable. Please, keep in mind that
an environment variable takes precedence over a shell variable of the same name.
variable
name of the counter variable
items
space separated item list
commands
commands to execute
Example
-------
::
=> env set c
=> for c in 1 2 3; do echo item ${c}; done
item 1
item 2
item 3
=> echo ${c}
3
=> env set c x
=> for c in 1 2 3; do echo item ${c}; done
item x
item x
item x
=>
The first line ensures that there is no environment variable *c*. Hence in the
first loop the shell variable *c* is printed.
After defining an environment variable of name *c* it takes precedence over the
shell variable and the environment variable is printed.
Return value
------------
The return value $? after the done statement is the return value of the last
statement executed in the loop.
::
=> for i in true false; do ${i}; done; echo $?
1
=> for i in false true; do ${i}; done; echo $?
0