title: Execute command parsed from a string containing arguments with spaces
body: <p>I would like to execute a command which is given by a variable (Variable <code>cmd</code> in this example):</p>
  
  <pre><code>cmd="echo 'First argument'"
  $cmd
  </code></pre>
  
  <p>Expected result would be:</p>
  
  <pre><code>First argument
  </code></pre>
  
  <p>BUT ... actual result is:</p>
  
  <pre><code>'First argument'
  </code></pre>
  
  <p>What? I don't understand why I can see single quotes in the output. After all, if the command (=content of variable $cmd) would be issued directly, then no quotes leak into the output, it behaves as desired:</p>
  
  <pre><code>$ echo 'First argument'
  First argument
  </code></pre>
  
  <p>To illustrate what I am trying to achieve in real life: in my deploy script there is a code block like this (strongly simplified, but you get the point):</p>
  
  <pre><code>#!/bin/bash
  function execute {
      cmd=$1
      echo "Executing $cmd ..."
  
      # execute the command:
      $cmd
  }    
  
  VERSION=1.0.2
  execute "git tag -a 'release-$VERSION'"
  </code></pre>
  
  <p>Now, Git would create a tag which contains single quotes:</p>
  
  <pre><code>git tag
  '1.0.2'
  </code></pre>
  
  <p>which is not what I want ...</p>
  
  <p>What to do?</p>
  
  <p>(Bash version: GNU bash 3.1.0)</p>
  
  <p>(I found a very similar issue, <a href="https://stackoverflow.com/questions/1983048/passing-a-string-with-spaces-as-a-function-argument-in-bash">here</a>, but the answer would not apply to my problem)</p>