mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-01 10:11:14 -03:00
doc_src: Continue the slog through the letter F.
We are using only :: in a synopsis for fishscript examples given of the command being documented.
This commit is contained in:
@@ -6,22 +6,18 @@ for - perform a set of commands multiple times
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
for VARNAME in [VALUES...]; COMMANDS...; end
|
||||
**for** *VARNAME* in [*VALUES*...]; *COMMANDS*...; **end**
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``for`` is a loop construct. It will perform the commands specified by ``COMMANDS`` multiple times. On each iteration, the local variable specified by ``VARNAME`` is assigned a new value from ``VALUES``. If ``VALUES`` is empty, ``COMMANDS`` will not be executed at all. The ``VARNAME`` is visible when the loop terminates and will contain the last value assigned to it. If ``VARNAME`` does not already exist it will be set in the local scope. For our purposes if the ``for`` block is inside a function there must be a local variable with the same name. If the ``for`` block is not nested inside a function then global and universal variables of the same name will be used if they exist.
|
||||
**for** is a loop construct. It will perform the commands specified by *COMMANDS* multiple times. On each iteration, the local variable specified by *VARNAME* is assigned a new value from *VALUES*. If *VALUES* is empty, *COMMANDS* will not be executed at all. The *VARNAME* is visible when the loop terminates and will contain the last value assigned to it. If *VARNAME* does not already exist it will be set in the local scope. For our purposes if the **for** block is inside a function there must be a local variable with the same name. If the **for** block is not nested inside a function then global and universal variables of the same name will be used if they exist.
|
||||
|
||||
Much like :ref:`set <cmd-set>`, ``for`` does not modify $status, but the evaluation of its subordinate commands can.
|
||||
Much like :ref:`set <cmd-set>`, **for** does not modify $status, but the evaluation of its subordinate commands can.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
for i in foo bar baz; echo $i; end
|
||||
@@ -37,8 +33,6 @@ Notes
|
||||
|
||||
The ``VARNAME`` was local to the for block in releases prior to 3.0.0. This means that if you did something like this:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
for var in a b c
|
||||
|
||||
Reference in New Issue
Block a user