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

Re: bash quoting question



On Fri, 12 Oct 2001, Nadav Har'El wrote:

> 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

Thanks. It worked

> 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).

Bash (bash2, actually) has arrays as well. The syntax is not as simple as
zsh (csh, right?), but it also works:

declare -a COMMAND
COMMAND=(program "parameters with ${SPACES}")
"${COMMAND[@]}"

-- 
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