title: Elegant way for verbose mode in scripts?
body: <p>When I write bash scripts I usually get the verbose mode this way (simplified):</p>
  
  <pre><code>_V=0
  
  while getopts "v" OPTION
  do
    case $OPTION in
      v) _V=1
         ;;
    esac
  done
  </code></pre>
  
  <p>and then every time I want a "verbose output" I type this:</p>
  
  <pre><code>[ $_V -eq 1 ] &amp;&amp; echo "verbose mode on" || echo "verbose mode off"
  </code></pre>
  
  <p>or for example this:</p>
  
  <pre><code>[ $_V -eq 1 ] &amp;&amp; command -v || command
  </code></pre>
  
  <p>Is there a way to do it more elegant? I was thinking about defining a function named "verbose" and type it instead of <code>[ $_V -eq 1 ]</code>, but this would only be a tiny improvement.</p>
  
  <p>I'm sure, there is more common way to do it…</p>