<story><title>Elegant Bash Conditionals</title><url>https://timvisee.com/blog/elegant-bash-conditionals/</url></story><parent_chain><item><author>lhorie</author><text>Something I&amp;#x27;ve come to internalize over the years is to always try to avoid being clever especially with lingua francas like Bash.&lt;p&gt;There &lt;i&gt;will&lt;/i&gt; be people - seasoned professional developers, even - reading these languages that don&amp;#x27;t know the first thing about them!&lt;p&gt;`[` is one of those things that are second nature for seasoned bash people but that are utterly ungoogleable by a bash beginner. Beginners don&amp;#x27;t know `[` is an executable, and it would never occur to them to `man [`. It can become quite the rabbit hole to figure out that there&amp;#x27;s also `[[` (which is NOT an executable), that `[ a &amp;gt; b ]` is &lt;i&gt;very very&lt;/i&gt; different from `[[ a &amp;gt; b ]]`, etc.&lt;p&gt;So do these people a favor and put the `if` there so they at least have some hope of stumbling upon a stack overflow post talking about some of this stuff.</text></item></parent_chain><comment><author>js2</author><text>&amp;quot;test&amp;quot; and its alias &amp;quot;[&amp;quot; are actually builtins:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.gnu.org&amp;#x2F;software&amp;#x2F;bash&amp;#x2F;manual&amp;#x2F;html_node&amp;#x2F;Bourne-Shell-Builtins.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.gnu.org&amp;#x2F;software&amp;#x2F;bash&amp;#x2F;manual&amp;#x2F;html_node&amp;#x2F;Bourne-Sh...&lt;/a&gt;&lt;p&gt;They also exist as executables for ancient backwards compatibility.&lt;p&gt;&amp;quot;[[&amp;quot; is a so-called &amp;quot;conditional construct&amp;quot;:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.gnu.org&amp;#x2F;software&amp;#x2F;bash&amp;#x2F;manual&amp;#x2F;html_node&amp;#x2F;Conditional-Constructs.html#Conditional-Constructs&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.gnu.org&amp;#x2F;software&amp;#x2F;bash&amp;#x2F;manual&amp;#x2F;html_node&amp;#x2F;Condition...&lt;/a&gt;&lt;p&gt;I have a somewhat quirky style and almost always use &amp;quot;if test ...&amp;quot; since I find it clearer than &amp;quot;[&amp;quot; and usually don&amp;#x27;t need the additional functionality that &amp;quot;[[&amp;quot; provides.</text></comment>
<story><title>Elegant Bash Conditionals</title><url>https://timvisee.com/blog/elegant-bash-conditionals/</url></story><parent_chain><item><author>lhorie</author><text>Something I&amp;#x27;ve come to internalize over the years is to always try to avoid being clever especially with lingua francas like Bash.&lt;p&gt;There &lt;i&gt;will&lt;/i&gt; be people - seasoned professional developers, even - reading these languages that don&amp;#x27;t know the first thing about them!&lt;p&gt;`[` is one of those things that are second nature for seasoned bash people but that are utterly ungoogleable by a bash beginner. Beginners don&amp;#x27;t know `[` is an executable, and it would never occur to them to `man [`. It can become quite the rabbit hole to figure out that there&amp;#x27;s also `[[` (which is NOT an executable), that `[ a &amp;gt; b ]` is &lt;i&gt;very very&lt;/i&gt; different from `[[ a &amp;gt; b ]]`, etc.&lt;p&gt;So do these people a favor and put the `if` there so they at least have some hope of stumbling upon a stack overflow post talking about some of this stuff.</text></item></parent_chain><comment><author>l0b0</author><text>&lt;p&gt;&lt;pre&gt;&lt;code&gt;  $ type -a [
  [ is a shell builtin
  [ is &amp;#x2F;usr&amp;#x2F;bin&amp;#x2F;[
  $ type -a [[
  [[ is a shell keyword&lt;/code&gt;&lt;/pre&gt;</text></comment>