[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "${x-"$@"}" expansion
From: |
Piotr Grzybowski |
Subject: |
Re: "${x-"$@"}" expansion |
Date: |
Wed, 27 Apr 2016 10:54:10 +0200 |
On 26 Apr 2016, at 21:03, Grisha Levit wrote:
> This behavior seems very strange. This example is with $@ but it seems the
> same for ${array[@]}
>
> The manual says for ${parameter:-word}:
>
> > If parameter is unset or null, the expansion of word is substituted.
>
> In this case, $@ is expanded as if it was quoted (even if 'word' is not
> quoted) and the outer quotes do no serve to quote the expansion of $@.
>
> $ set -- '1 1' '2 2'; unset x
> $ v=( "${x-$@}" ); declare -p v
> declare -a v=([0]="1 1" [1]="2 2")
I gather, you expect $* behavior?
#set -- '1 1' '2 2'; unset x
#v=( "${x-$*}" ); declare -p v
declare -a v='([0]="1 1 2 2")'
cheers,
pg