On 4/26/16 3:03 PM, 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 i
On Wed, Apr 27, 2016 at 07:33:25AM -0400, Grisha Levit wrote:
> Sorry that wasn???t very clear. I only included that case to demonstrate that
> seemingly contradictory things are happening:
>
>- "${_+$@}" expands each positional parameter to a separate word,
>following the usual "$@" behav
Sorry that wasn’t very clear. I only included that case to demonstrate that
seemingly contradictory things are happening:
- "${_+$@}" expands each positional parameter to a separate word,
following the usual "$@" behavior
- The usual "$@" behavior is to expand to 0 words if there are no
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 exp
The same is true for + expansion:
Multiple words:
$ set -- 1 2; v=( "${#+$@}" ); declare -p v
declare -a v=([0]="1" [1]="2")
Empty string:
$ set --; v=( "${#+$@}" ); declare -p v
declare -a v=([0]="")
Nothing:
$ set --; v=( "${#+${#+$@}}" ); declare -p v
declare -a v=()
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