[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash quoting question



Hi

I'm trying to write a script:

  ...
NAME_SERVER="192.168.1.200"
DNS_RESOLVE="/usr/bin/adnsresfilter --config 'nameserver ${NAME_SERVER}'"
 ...
  | ${DNS_RESOLVE} \
 ...

That is, the command above shsould recieve a parameter that contains a
space, and thus has to be quoted. Its value needs to be expanded from
anther variable.

The result (with set -x):

  ...
+ NAME_SERVER=192.168.1.200
+ DNS_RESOLVE=/usr/bin/adnsresfilter --config 'nameserver 192.168.1.200'
  ...
+ /usr/bin/adnsresfilter --config ''\''nameserver' '192.168.1.200'\'''
adnsresfilter: bad usage: no non-option arguments are allowed
  ...

It appears that the shell treats the value of DNS_RESOLVE as seperate
words, and even bothers quoting the "'" marks.

Any way around this?

(Scanning the bash manual yeilds nothing)

-- 
Tzafrir Cohen
mailto:tzafrir@technion.ac.il
http://www.technion.ac.il/~tzafrir


=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il