title: shell: What is the purpose of ${var:-} when var is unset or null?
body: <p>In my <a href="https://gist.github.com/cfe6dd30155bf378cfe90a7a2cd7f816" rel="nofollow noreferrer">Linux Mint 17.2 <code>/etc/bash.bashrc</code></a> I see the following:</p>
  
  <pre><code># set variable identifying the chroot you work in (used in the prompt below)
  if [ -z &quot;${debian_chroot:-}&quot; ] &amp;&amp; [ -r /etc/debian_chroot ]; then
      debian_chroot=$(cat /etc/debian_chroot)
  fi
  </code></pre>
  <p>This is the first reference to the token <code>debian_chroot</code>.</p>
  <p>Why does this code use <code>${debian_chroot:-}</code> instead of just <code>$debian_chroot</code>?</p>
  <p>Bash's <a href="https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion" rel="nofollow noreferrer">Shell Parameter Expansion</a> says:</p>
  <blockquote>
  <p>${parameter:-word}</p>
  <p>If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.</p>
  </blockquote>
  <p>Here, &quot;word&quot; is null, so why bother substituting null for null?</p>