Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-07 Thread Stephane CHAZELAS
2011-11-6, 21:02(-06), Peng Yu: [...] #!/usr/bin/env bash verbatim_string= a b c ( a'b | args=`echo \$verbatim_string\ | sed -f quoteverb.sed` cmd=echo $args eval $cmd ~$ ./main.sh a b c ( a'b | Either: #! /bin/sh verbatim_string= a b c ( a'b | cmd='(set -f; IFS= ; echo

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-07 Thread Peng Yu
Hi Clark, What do you mean by 1 long argument? [bash-4.2.10] # cat foo.sh v=  a b c ( a'b | set -o noglob a=( $v ) set +o noglob for i in ${a[@]}; do     echo $i done [bash-4.2.10] # bash foo.sh a b c ( a'b | [bash-4.2.10] # I misunderstood the usage of ${args[@]}. I though

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-07 Thread Greg Wooledge
On Mon, Nov 07, 2011 at 08:50:25AM +, Stephane CHAZELAS wrote: cmd='(set -f; IFS= ; echo $verbatim_string)' eval $cmd http://mywiki.wooledge.org/BashFAQ/050 -- I'm trying to put a command in a variable, but the complex cases always fail!

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-07 Thread Dennis Williamson
On Mon, Nov 7, 2011 at 7:23 AM, Peng Yu pengyu...@gmail.com wrote: Hi Clark, What do you mean by 1 long argument? [bash-4.2.10] # cat foo.sh v=  a b c ( a'b | set -o noglob a=( $v ) set +o noglob for i in ${a[@]}; do     echo $i done [bash-4.2.10] # bash foo.sh a b c ( a'b |

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-07 Thread Peng Yu
On Mon, Nov 7, 2011 at 8:29 AM, Dennis Williamson dennistwilliam...@gmail.com wrote: On Mon, Nov 7, 2011 at 7:23 AM, Peng Yu pengyu...@gmail.com wrote: Hi Clark, What do you mean by 1 long argument? [bash-4.2.10] # cat foo.sh v=  a b c ( a'b | set -o noglob a=( $v ) set +o noglob for i

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-06 Thread Clark J. Wang
(Added back the bash list) On Mon, Nov 7, 2011 at 11:50 AM, Peng Yu pengyu...@gmail.com wrote: On Sun, Nov 6, 2011 at 9:30 PM, Clark J. Wang dearv...@gmail.com wrote: On Mon, Nov 7, 2011 at 11:02 AM, Peng Yu pengyu...@gmail.com wrote: Hi, Suppose that I have a verbatim string a b c

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-06 Thread Peng Yu
Hi Clark, v=  a b c ( a'b | a=( $v ) echo ${a[@]} There's a @ char here. I see. It's my mistake. But I want to pass the 6 short arguments instead of 1 long argument to echo. (echo is just an example, it can be any command that accepts multiple arguments.) ~$ cat ./main1.sh

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-06 Thread Clark J. Wang
On Mon, Nov 7, 2011 at 12:56 PM, Peng Yu pengyu...@gmail.com wrote: Hi Clark, v= a b c ( a'b | a=( $v ) echo ${a[@]} There's a @ char here. I see. It's my mistake. But I want to pass the 6 short arguments instead of 1 long argument to echo. What do you mean by 1 long