title: Correct way to check for a command line flag in bash
body: <p>In the middle of a script, I want to check if a given flag was passed on the command line. The following does what I want but seems ugly:</p>
  
  <pre><code>if echo $* | grep -e "--flag" -q
  then
    echo "&gt;&gt;&gt;&gt; Running with flag"
  else
    echo "&gt;&gt;&gt;&gt; Running without flag"
  fi
  </code></pre>
  
  <p><em>Is there a better way?</em></p>
  
  <p>Note: I explicitly <em>don't</em> want to list all the flags in a switch/getopt. (In this case any such things would become half or more of the full script. Also the bodies of the if just set a set of vars) </p>