bug-bash
[Top][All Lists]
Advanced

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

Re: What is the best to pass an array with specially characters as comma


From: Clark J. Wang
Subject: Re: What is the best to pass an array with specially characters as command line arguments?
Date: Mon, 7 Nov 2011 12:53:51 +0800

(Added back the bash list)

On Mon, Nov 7, 2011 at 11:50 AM, Peng Yu <pengyu.ut@gmail.com> wrote:

> On Sun, Nov 6, 2011 at 9:30 PM, Clark J. Wang <dearvoid@gmail.com> wrote:
> > On Mon, Nov 7, 2011 at 11:02 AM, Peng Yu <pengyu.ut@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> Suppose that I have a verbatim string "  a b c ( a'b | " in bash, and
> >> I want to pass them as 6 command line arguments. I have to the
> >> following conversion using quoteverb.sed to pass the 6 arguments
> >> correctly to echo, which is a little bit cumbersome. I'm wondering if
> >> there is any better way to pass the 6 arguments.
> >
> > v="  a b c ( a'b | "
> > a=( $v )
> > echo "${a[@]}"
>

There's a @ char here.


> >
> > And you may need to temporariliy enable the noglob option before that.
>
> Not working. See below. Also, 'echo "${a[@]}"' will only pass 1
> argument to echo, I want to pass 6 separate arguments to echo.
>
> ~$ cat main1.sh
> #!/usr/bin/env bash
>
> set -o noglob
> verbatim_string="  a b c ( a'b | "
>
> args=( $verbatim_string )
> set +o noglob
>
> echo "${args}"
> ~$ ./main1.sh
> a
>
>
>
>
> --
> Regards,
> Peng
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]