Re: converting array to string by quoting each element for eval

2011-11-15 Thread Peng Yu
>  Then why don't you post that? Please take a look and see if you have a better solution than the following code without using quotearg.sh. /tmp/tmp$ ll * c d: total 0 -rw-r--r-- 1 pengy wheel 0 2011-11-15 20:18:11 xx a b: total 0 -rw-r--r-- 1 pengy wheel 0 2011-11-15 20:18:15 yy /tmp/tmp$ ../c

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Chris F.A. Johnson
On Tue, 15 Nov 2011, Peng Yu wrote: On Tue, Nov 15, 2011 at 6:43 PM, Chris F.A. Johnson wrote: On Tue, 15 Nov 2011, Peng Yu wrote:    In any case, combining a command and its arguments in a single    string is almost always the wrong way to go about it. Please compare the two scripts and s

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Peng Yu
On Tue, Nov 15, 2011 at 6:43 PM, Chris F.A. Johnson wrote: > On Tue, 15 Nov 2011, Peng Yu wrote: > >>>    In any case, combining a command and its arguments in a single >>>    string is almost always the wrong way to go about it. >> >> Please compare the two scripts and see if the second one makes

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Chris F.A. Johnson
On Tue, 15 Nov 2011, Peng Yu wrote:    In any case, combining a command and its arguments in a single    string is almost always the wrong way to go about it. Please compare the two scripts and see if the second one makes more sense. /tmp$ cat not_convert_args_to_string.sh #!/bin/bash option

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Peng Yu
>    In any case, combining a command and its arguments in a single >    string is almost always the wrong way to go about it. Please compare the two scripts and see if the second one makes more sense. /tmp$ cat not_convert_args_to_string.sh #!/bin/bash options="$2" find $1 $options echo find $1

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Chris F.A. Johnson
On Tue, 15 Nov 2011, Peng Yu wrote:   Why not use the array instead of making it into a single string? $cmd "${args[@]}"   Why are you using eval or quotearg.sh? It sounds as if you are   making the process more complicated than it need be. For the examples that I gave, probably it is not ne

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Peng Yu
>   Why not use the array instead of making it into a single string? > > $cmd "${args[@]}" > >   Why are you using eval or quotearg.sh? It sounds as if you are >   making the process more complicated than it need be. For the examples that I gave, probably it is not necessary. I'm yet to make a co

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Chris F.A. Johnson
On Tue, 15 Nov 2011, Peng Yu wrote: Hi, I find that I have to make a program quotearg.sh to convert an array to a string by quoting each element. So that it be used for eval. I'm not sure if there is a way that I can do eval in bash without having to use quotearg.sh. If there is no such a way,

converting array to string by quoting each element for eval

2011-11-15 Thread Peng Yu
Hi, I find that I have to make a program quotearg.sh to convert an array to a string by quoting each element. So that it be used for eval. I'm not sure if there is a way that I can do eval in bash without having to use quotearg.sh. If there is no such a way, should quotearg.sh be added in bash (i