summaryrefslogtreecommitdiff
path: root/devdocs/bash/command-grouping.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/bash/command-grouping.html')
-rw-r--r--devdocs/bash/command-grouping.html13
1 files changed, 13 insertions, 0 deletions
diff --git a/devdocs/bash/command-grouping.html b/devdocs/bash/command-grouping.html
new file mode 100644
index 00000000..abb18c59
--- /dev/null
+++ b/devdocs/bash/command-grouping.html
@@ -0,0 +1,13 @@
+<h1 class="subsubsection">Grouping Commands</h1> <p>Bash provides two ways to group a list of commands to be executed as a unit. When commands are grouped, redirections may be applied to the entire command list. For example, the output of all the commands in the list may be redirected to a single stream. </p> <dl compact> <dt><span><code>()</code></span></dt> <dd>
+<div class="example"> <pre class="example">( list )
+</pre>
+</div> <p>Placing a list of commands between parentheses forces the shell to create a subshell (see <a href="command-execution-environment">Command Execution Environment</a>), and each of the commands in <var>list</var> is executed in that subshell environment. Since the <var>list</var> is executed in a subshell, variable assignments do not remain in effect after the subshell completes. </p> </dd> <dt id="index-_007b"><span><code>{}</code></span></dt> <dd>
+ <div class="example"> <pre class="example">{ list; }
+</pre>
+</div> <p>Placing a list of commands between curly braces causes the list to be executed in the current shell context. No subshell is created. The semicolon (or newline) following <var>list</var> is required. </p>
+</dd> </dl> <p>In addition to the creation of a subshell, there is a subtle difference between these two constructs due to historical reasons. The braces are reserved words, so they must be separated from the <var>list</var> by <code>blank</code>s or other shell metacharacters. The parentheses are operators, and are recognized as separate tokens by the shell even if they are not separated from the <var>list</var> by whitespace. </p> <p>The exit status of both of these constructs is the exit status of <var>list</var>. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 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/Command-Grouping.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html</a>
+ </p>
+</div>