title: cURL throwing globbing error when JSON data in variable contains a space
body: <p>Using bash v4.3.48(1) on Ubuntu 16.04.2 LTS and bash v3.2.57 on macOS Sierra 10.12.5 I have this code which POSTs JSON data stored in a variable:</p>
  
  <pre><code>#1    
  JSON_DATA="Test"; \
  curl -X POST "https://www.techotaku.com/json.php" \
      -H "Content-Type: application/json" \
      -d '{"data":"'$JSON_DATA'"}'
  </code></pre>
  
  <p>This returns:</p>
  
  <pre><code>Array
  (
      [data] =&gt; Test
  )
  </code></pre>
  
  <p>However, if $JSON_DATA contains a space...</p>
  
  <pre><code>#2
  JSON_DATA="A Test"; \
  curl -X POST "https://www.techotaku.com/json.php" \
      -H "Content-Type: application/json" \
      -d '{"data":"'$JSON_DATA'"}'
  </code></pre>
  
  <p>...it throws an error:</p>
  
  <pre><code>curl: (3) [globbing] unmatched close brace/bracket in column 6
  </code></pre>
  
  <p>I thought this might be due to incorrect use of quotes, but if I echo the JSON data...</p>
  
  <pre><code>echo '{"data":"'$JSON_DATA'"}'
  </code></pre>
  
  <p>...it appears well-formed:</p>
  
  <pre><code>{"data":"A Test"}
  </code></pre>
  
  <p>Also, if I include the JSON data as a string and not a variable, it works.</p>
  
  <pre><code>#3
  curl -X POST "https://www.techotaku.com/json.php" \
      -H "Content-Type: application/json" \
      -d '{"data":"A Test"}'
  </code></pre>
  
  <p>The only way I can get it to work if the variable contains a space is to enclose the JSON data in double-quotes and escape the literal double-quotes in the string:</p>
  
  <pre><code>#4    
  JSON_DATA="A Test"; \
  curl -X POST "https://www.techotaku.com/json.php" \
      -H "Content-Type: application/json" \
      -d "{\"data\":\"$JSON_DATA\"}"
  </code></pre>
  
  <p>I would have thought that all 4 examples would have worked. So, can anyone throw any light on why only examples 1,3 and 4 work and example 2 doesn't?</p>
  
  <p>Many thanks, Steve.  </p>