given the context below ..
Is there any magic syntax that can be inserted into the $ WGETOPT definition to allow the $ USERAGENT variable to be βabsorbedβ and still allow the wget command to be invoked, as in syntax 1 ? I'm currently resorting to using "eval", which I don't like, but maybe this is the only way to do what I want 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 leads to:
DEBUG output created by Wget 1.11.4 on Windows-MinGW. Enqueuing http:
Obviously, the bash interpreter could not stand the \.
# 2 leads to:
wget: --cut-dirs: Invalid number `3 -r -l10 -dnv -x -H --timesta.. ..indows NT 5.1)"'.'
here, the double quote result is passed in with one argument, which wget parses the named parameter, and then accepts (correctly) that the rest is its argument, regardless of the space.
# 3 works, and I use it, but I remember how I was punished for using evil / eval!
# 4 I will assume that it works fine, I have not tested it, because this is not how I want to do it.
.. hence the question.
amuses
source share