title: how to make nested double quotes survive the bash interpreter?
body: <p>given the context below..</p>
  
  <p>does any magic syntax exist that can be inserted in the definition of $WGETOPT to allow the $USERAGENT variable to be 'absorbed', and still allow for a call to the wget command as in <strong>syntax 1</strong>? i've currently resorted to using 'eval' which i'm not happy with, but maybe this is the only way i can do what i want to here?!</p>
  
  <pre><code>#params
  USERAGENT="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
  PROXYSWITCH=off
  WGET=wget
  WGETOPT="--cut-dirs=3 -r -l10 -dnv -x -H --timestamping --limit-rate=100K --proxy=$PROXYSWITCH -U \"$USERAGENT\"" 
  WGETOPTminusUSERAGENT="-cut-dirs=3 -r -l10 -dnv -x -H --timestamping --limit-rate=100K --proxy=$PROXYSWITCH" 
  URL=http://blah
  
  #commands
  #1.
      $WGET $WGETOPT $URL
  #2.
      $WGET "$WGETOPT" $URL
  #3.
      eval "$WGET $WGETOPT $URL"
  #4. 
      $WGET $WGETOPTminusUSERAGENT -U "$USERAGENT" $URL
  </code></pre>
  
  <p><strong>#1</strong>. results in:</p>
  
  <pre><code>DEBUG output created by Wget 1.11.4 on Windows-MinGW.
  Enqueuing http://(compatible;/ at depth 0
  Queue count 1, maxcount 1.
  Host `(compatible;' has not issued a general basic challenge.
  ...
  Setting --user-agent (useragent) to "Mozilla/4.0
  ...
  </code></pre>
  
  <p>it's obvious why, the "\" didn't 'survive' the bash interpreter.</p>
  
  <p><strong>#2</strong>. results in:</p>
  
  <pre><code>wget: --cut-dirs: Invalid number `3 -r -l10 -dnv -x -H --timesta.. ..indows NT 5.1)"'.'
  </code></pre>
  
  <p>here, the double-quotes result in a single argument being passed which wget parses a named parameter from, and then assumes (correctly) that the rest is its argument, regardless of white space.</p>
  
  <p><strong>#3</strong>. works, and i'm using it, but i do remember being chastised for using the evil/eval! </p>
  
  <p><strong>#4</strong>. i'll assume works fine, i didn't test it because that's not how i want to do it!!</p>
  
  <p>..hence the question. </p>
  
  <p>cheers</p>