bug-bash
[Top][All Lists]
Advanced

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

"${x-"$@"}" expansion


From: Grisha Levit
Subject: "${x-"$@"}" expansion
Date: Tue, 26 Apr 2016 15:03:49 -0400

This behavior seems very strange.  This example is with $@ but it seems the same for address@hidden

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 address@hidden

$ set -- '1 1' '2 2'; unset x
$ v=( "address@hidden" ); declare -p v
declare -a v=([0]="1 1" [1]="2 2")

In this case though, the expansion is an empty string rather than nothing so it seems that a different set of rules is being followed:

$ set --
$ v=("$@"); declare -p v          # obviously
declare -a v=()
$ v=( "address@hidden@}" ); declare -p v   # ?
declare -a v=([0]="")

The following is strange, in light of the above:

$ v=("address@hidden@address@hidden"); declare -p v
declare -a v=()


reply via email to

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