[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash quoting question
On Fri, Oct 12, 2001, Tzafrir Cohen wrote about "bash quoting question":
> It appears that the shell treats the value of DNS_RESOLVE as seperate
> words, and even bothers quoting the "'" marks.
>
> Any way around this?
In bash, the only solution I can think of now is using eval, like
A="ls 'a b'"
echo | eval $A
(maybe someone else can think of a better way. *NEVER* do this if the value
of $A may come from an unchecked user parameter!!)
In Zsh, the way to do this is the following:
A=(ls 'a b')
echo | $A
(Note using an array instead of string. Zsh had a major overhaul of the
"traditional" handling of whitespace by other bourne-like shells).
This is safer than the eval solution because the following doesn't remove your
files:
USERPAR="; rm -rf /" # imagine the user passes this!
A=(ls $USERPAR)
echo | $A
only does:
ls: ; rm -rf /: No such file or directory
--
Nadav Har'El | Friday, Oct 12 2001, 25 Tishri 5762
nyh@math.technion.ac.il |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Earth First! We can strip-mine the other
http://nadav.harel.org.il |planets later...
=================================================================
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