title: Variable Substitution
body: <p>Having an issue in FreeBSD 8.3 using an SH shell script.</p>
  
  <p>The following date command works in FreeBSD </p>
  
  <pre><code>date -j -f "%Y/%m/%d" "$ii" '+%s'
  </code></pre>
  
  <p>The script needs to run in both FreeBSD and Ubuntu, but the date function above does not work in Ubuntu. </p>
  
  <p>This works in Ubuntu </p>
  
  <pre><code>date --date="$ii" +"%s"
  </code></pre>
  
  <p>So I want to have a variable to switch between these two depending on the OS.</p>
  
  <pre><code># Options (freebsd/linux)
  recdate=freebsd
  
  ii=2014/06/06
  
  if [ "$recdate" == "freebsd" ]; then
     recdate="\`date \-j \-f \"\%Y/\%m/\%d\" \"\$ii\" \'\+\%s\'\`"
  else
     recdate="\`date \-\-date\=\"\$ii\" \+\"\%s\"\`"
  fi
  </code></pre>
  
  <p>I have tried multiple escaping and quoting without success.</p>
  
  <p>The error is as follows (using set -x):</p>
  
  <pre><code>+ [ '' == freebsd ]
  + date --date= +%s
  date: illegal option -- -
  usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
         [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
  + recdate=''
  </code></pre>