Commit 93f7a536 authored by Alexander Schoch's avatar Alexander Schoch
Browse files

fix error in one bash line

parent d0f642d8
Pipeline #131879 passed with stage
in 16 seconds
......@@ -267,7 +267,7 @@ pwd</code></pre>
<h2 data-number="6.2" id="grouping-commands"><span class="header-section-number">6.2</span> Grouping Commands</h2>
<p>Now, what if you want to execute multiple commands if the first one fails? Going from the example above, when <code>mkdir folder</code> fails, you might want to print an error message <em>and</em> return 1.</p>
<p>This can be done by enclosing these two commands in single curly braces:</p>
<pre><code>mkdir folder || { echo &#39;Could not create folder&#39;; exit 1 }</code></pre>
<pre><code>mkdir folder || { echo &#39;Could not create folder&#39;; exit 1; }</code></pre>
<p>The two commands in curly braces are treated as an unit, and if the first command fails, both will be executed.</p>
<p>Note that you need to include spaces between the curly braces and the commands. If there were no spaces, bash would look for a command named <code>{echo</code> and fail to find it.</p>
<p>There’s a semicolon separating the two commands. The semicolon has the same function as a line break: it makes bash consider both parts as individual commands-plus-arguments.</p>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment