 <p>I would use:</p> <pre><code>if [ $YARN -eq 1 ]; then npm install -g yarn &amp;&amp; echo "yarn installed" fi </code></pre> <p>My bash reports 1 if program is not installed and i am not sure if value 1 will pass the -z test</p>