<story><title>Stupid Unix Tricks</title><url>https://sneak.berlin/20191011/stupid-unix-tricks/</url></story><parent_chain><item><author>asaph</author><text>&amp;gt; Don’t try to install things with brew if brew is not installed:&lt;p&gt;&lt;pre&gt;&lt;code&gt;   if which brew 2&amp;gt;&amp;amp;1 &amp;#x2F;dev&amp;#x2F;null ; then
        brew install jq
   fi
&lt;/code&gt;&lt;/pre&gt;
This just hides a useful error message (brew not installed). I would rather just see that error message (either interactively or in a log) and have the script fail. Hiding the error message just leads to an eventual failure down the road when jq is invoked.</text></item></parent_chain><comment><author>reacweb</author><text>In bash, there is the build-in command named &amp;quot;command&amp;quot;. I have used it for the same purpose, like in:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    command -v brew &amp;gt;&amp;#x2F;dev&amp;#x2F;null &amp;amp;&amp;amp; brew install jq&lt;/code&gt;&lt;/pre&gt;</text></comment>
<story><title>Stupid Unix Tricks</title><url>https://sneak.berlin/20191011/stupid-unix-tricks/</url></story><parent_chain><item><author>asaph</author><text>&amp;gt; Don’t try to install things with brew if brew is not installed:&lt;p&gt;&lt;pre&gt;&lt;code&gt;   if which brew 2&amp;gt;&amp;amp;1 &amp;#x2F;dev&amp;#x2F;null ; then
        brew install jq
   fi
&lt;/code&gt;&lt;/pre&gt;
This just hides a useful error message (brew not installed). I would rather just see that error message (either interactively or in a log) and have the script fail. Hiding the error message just leads to an eventual failure down the road when jq is invoked.</text></item></parent_chain><comment><author>aasasd</author><text>You don&amp;#x27;t need to check for `brew` in each task if they&amp;#x27;re run automatically. Just have one task that checks for `brew`.&lt;p&gt;With a proper dependency graph, the tasks installing things would depend on the task `brew-installed`.&lt;p&gt;This, of course, is leaving alone the point that installing stuff on startup is weird, doubly so with brew which is pretty slow.</text></comment>