title: bash: expanding function arguments
body: <p>I have an issue with a bash function for a shell script i'm writing. The function is as follows:      </p>
  
  <pre><code>do_command() {
    if [[ $DRY_RUN ]]; then
      echo $@
    else
      $@
    fi
  }
  </code></pre>
  
  <p>Function is simple, if the DRY_RUN flag is set we just print the method otherwise it is executed. This works well for most commands except git tag command that I have tried different versions of like:</p>
  
  <pre><code>do_command git tag -a $NEW_VERSION -m '$INPUT_COMMENT'
  </code></pre>
  
  <p>That actually executes the tag command, but give the comment <em>$INPUT_COMMENT</em></p>
  
  <p>I have tried 2 other versions that gives the correct echo output, but doesn't allow me to execute the git tag command.</p>
  
  <pre><code>do_command git tag -a $NEW_VERSION -m "$INPUT_COMMENT"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>do_command git tag -a $NEW_VERSION -m "\"$INPUT_COMMENT\""
  </code></pre>
  
  <p>Is there some way to make both echo and git command work in this call? Or do I need to parse in the do_command version?</p>