diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/bash/lists.html | |
new repository
Diffstat (limited to 'devdocs/bash/lists.html')
| -rw-r--r-- | devdocs/bash/lists.html | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/bash/lists.html b/devdocs/bash/lists.html new file mode 100644 index 00000000..c4ba990e --- /dev/null +++ b/devdocs/bash/lists.html @@ -0,0 +1,12 @@ +<h1 class="subsection">Lists of Commands</h1> <p>A <code>list</code> is a sequence of one or more pipelines separated by one of the operators ‘<samp>;</samp>’, ‘<samp>&</samp>’, ‘<samp>&&</samp>’, or ‘<samp>||</samp>’, and optionally terminated by one of ‘<samp>;</samp>’, ‘<samp>&</samp>’, or a <code>newline</code>. </p> <p>Of these list operators, ‘<samp>&&</samp>’ and ‘<samp>||</samp>’ have equal precedence, followed by ‘<samp>;</samp>’ and ‘<samp>&</samp>’, which have equal precedence. </p> <p>A sequence of one or more newlines may appear in a <code>list</code> to delimit commands, equivalent to a semicolon. </p> <p>If a command is terminated by the control operator ‘<samp>&</samp>’, the shell executes the command asynchronously in a subshell. This is known as executing the command in the <em>background</em>, and these are referred to as <em>asynchronous</em> commands. The shell does not wait for the command to finish, and the return status is 0 (true). When job control is not active (see <a href="job-control">Job Control</a>), the standard input for asynchronous commands, in the absence of any explicit redirections, is redirected from <code>/dev/null</code>. </p> <p>Commands separated by a ‘<samp>;</samp>’ are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed. </p> <p><small>AND</small> and <small>OR</small> lists are sequences of one or more pipelines separated by the control operators ‘<samp>&&</samp>’ and ‘<samp>||</samp>’, respectively. <small>AND</small> and <small>OR</small> lists are executed with left associativity. </p> <p>An <small>AND</small> list has the form </p> +<div class="example"> <pre class="example">command1 && command2 +</pre> +</div> <p><var>command2</var> is executed if, and only if, <var>command1</var> returns an exit status of zero (success). </p> <p>An <small>OR</small> list has the form </p> +<div class="example"> <pre class="example">command1 || command2 +</pre> +</div> <p><var>command2</var> is executed if, and only if, <var>command1</var> returns a non-zero exit status. </p> <p>The return status of <small>AND</small> and <small>OR</small> lists is the exit status of the last command executed in the list. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br>Licensed under the GNU Free Documentation License.<br> + <a href="https://www.gnu.org/software/bash/manual/html_node/Lists.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Lists.html</a> + </p> +</div> |
