title: How do I test for an empty string in a Bash case statement?
body: <p>I have a Bash script that performs actions based on the value of a variable. The general syntax of the case statement is:</p>
  
  <pre><code>case ${command} in
     start)  do_start ;;
     stop)   do_stop ;;
     config) do_config ;;
     *)      do_help ;;
  esac
  </code></pre>
  
  <p>I'd like to execute a default routine if no command is provided, and <code>do_help</code> if the command is unrecognized. I tried omitting the case value thus:</p>
  
  <pre><code>case ${command} in
     )       do_default ;;
     ...
     *)      do_help ;;
  esac
  </code></pre>
  
  <p>The result was predictable, I suppose:</p>
  
  <pre><code>syntax error near unexpected token `)'
  </code></pre>
  
  <p>Then I tried using a regex:</p>
  
  <pre><code>case ${command} in
     ^$)     do_default ;;
     ...
     *)      do_help ;;
  esac
  </code></pre>
  
  <p>With this, an empty <code>${command}</code> falls through to the <code>*</code> case.</p>
  
  <p>Am I trying to do the impossible?</p>