given the context below..
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 syntax 1? 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?!
#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
#1. results in:
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
...
it's obvious why, the "\" didn't 'survive' the bash interpreter.
#2. results in:
wget: --cut-dirs: Invalid number `3 -r -l10 -dnv -x -H --timesta.. ..indows NT 5.1)"'.'
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.
#3. works, and i'm using it, but i do remember being chastised for using the evil/eval!
#4. i'll assume works fine, i didn't test it because that's not how i want to do it!!
..hence the question.
cheers