[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 "Re: bash quoting question":
> > In Zsh, the way to do this is the following:
> > 	A=(ls 'a b')
> > 	echo | $A
> >
> Bash (bash2, actually) has arrays as well. The syntax is not as simple as
> zsh (csh, right?), but it also works:

I didn't insult your shell, so why are you insulting mine? :) Comparing it
to csh...

Anyway, in csh, I can't think of any way to do this without eval. If you
set an array, like

	set A=(ls 'a b')

Then $A[2] is correct
	$ echo $A[2]
	a b

but running
	$A
splits the words another time (a wrong thing to do, in my opinion), and results
in
	ls: a: No such file or directory
	ls: b: No such file or directory

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

Wow. That last line is ugly!
 [ok, ok, now I insulted your shell too ;) ]

-- 
Nadav Har'El                        |      Friday, Oct 12 2001, 25 Tishri 5762
nyh@math.technion.ac.il             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Why aren't fishmongers generous? Their
http://nadav.harel.org.il           |business makes them selfish.

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