[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: |
Peng Yu |
Subject: |
Re: What is the best to pass an array with specially characters as command line arguments? |
Date: |
Mon, 7 Nov 2011 09:20:15 -0600 |
On Mon, Nov 7, 2011 at 8:29 AM, Dennis Williamson
<dennistwilliamson@gmail.com> wrote:
> On Mon, Nov 7, 2011 at 7:23 AM, Peng Yu <pengyu.ut@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
>>> |
>>> [bash-4.2.10] #
>>
>>
>> I misunderstood the usage of "${args[@]}". I though it returns only
>> one long argument " a b c ( a'b | ", but it actually expanded to 6
>> short arguments "a", "b", "c", "(", "a'b" and "|". Thanks for
>> clarification.
>>
>>
>>
>> --
>> Regards,
>> Peng
>>
>>
>
> If you use "${args[*]}" (with quotes and an asterisk instead of an at
> sign), the result is one long argument. Otherwise, it's split.
Thanks! I didn't notice this difference before.
--
Regards,
Peng
- What is the best to pass an array with specially characters as command line arguments?, Peng Yu, 2011/11/06
- Message not available
- Message not available
- Re: What is the best to pass an array with specially characters as command line arguments?, Clark J. Wang, 2011/11/06
- Re: What is the best to pass an array with specially characters as command line arguments?, Peng Yu, 2011/11/06
- Re: What is the best to pass an array with specially characters as command line arguments?, Clark J. Wang, 2011/11/07
- Re: What is the best to pass an array with specially characters as command line arguments?, Peng Yu, 2011/11/07
- Re: What is the best to pass an array with specially characters as command line arguments?, Dennis Williamson, 2011/11/07
- Re: What is the best to pass an array with specially characters as command line arguments?,
Peng Yu <=
Re: What is the best to pass an array with specially characters as command line arguments?, Stephane CHAZELAS, 2011/11/07