title: Execute command containing quotes from shell variable
body: <p>I'm currently having problems to execute a command from a shell variable. </p>
  
  <p>In general the following works as expected:</p>
  
  <pre><code>COMMAND="echo A"
  echo $COMMAND
  $COMMAND
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>echo A
  A
  </code></pre>
  
  <p>But if I do</p>
  
  <pre><code>COMMAND="su aUser -s /bin/bash -c 'echo A'"
  echo $COMMAND
  $COMMAND
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>su aUser -s /bin/bash -c 'echo A'
  Password: 
  A': -c: line 0: unexpected EOF while looking for matching `''
  A': -c: line 1: syntax error: unexpected end of file
  </code></pre>
  
  <p>If I enter the line</p>
  
  <pre><code>su aUser -s /bin/bash -c 'echo A'
  </code></pre>
  
  <p>directly it works as expected.</p>
  
  <p>It seems my assumption that $COMMAND is equal to entering the content as command directly is wrong.</p>
  
  <h2>Questions</h2>
  
  <p>1) Does anyone know how I can run the command from a variable?</p>
  
  <p>2) What exactly is the difference between</p>
  
  <pre><code>COMMAND="command"
  $COMMAND
  </code></pre>
  
  <p>and</p>
  
  <pre><code>command
  </code></pre>
  
  <p>?</p>