title: BASH - Mosquitto_pub command throws error if time has 'space' something is wrong with me code
body: <p>Hi i am an odd scenario</p>
  <p>if i send below command manually in terminal it works well</p>
  <pre><code>root@VPRT:/home/root# mosquitto_pub -h localhost -p 1883 -q 1 -d -t test -i localClientID -m '2020-07-14 15:03:27'
  </code></pre>
  <p>But same when sent from the Bash script I get error</p>
  <pre><code>Error: Unknown option '15:03:27''.
  </code></pre>
  <p>my shell script is :</p>
  <pre><code>#!/bin/bash
  mqttcmd=&quot;mosquitto_pub -h localhost -p 1883 -q 1 -d -t test  -i localClientID -m &quot;
  dateformat=&quot;%Y-%m-%d %H:%M:%S&quot;
  
  function my_date {
  date &quot;+${dateformat}&quot;
  }
  
  while true; do
  
  today=$(my_date)
  echo &quot;today : &quot; $today
  
  mystring=&quot;$mqttcmd&quot; 
  mystring+=&quot;'&quot;
  mystring+=&quot;$today&quot;
  mystring+=&quot;'&quot;
  
  #print
  echo ${mystring}
  
  #publish
  ${mystring}
  
  sleep 5
  
  done
  </code></pre>
  <p>if I send the same command that is PRINTED from the script it works but from the shell I get error.
  error only occurs with date format. if I send any other text from script it works. if I add the space between the date and time I get error.</p>
  <p>i am confused as the same date with space works if manually sent</p>