On 4/5/21 4:45 PM, konsolebox wrote:
set -u
array=()
__ref=array[@]
: "${array[@]}" # Reports nothing
This is a special case, mirroring the special case that POSIX carved out
for $@ and $* in 2009.
: "${!__ref}" # Unbound variable
But this is not. Bash looks for __ref, finds it with a value of array[@],
and attempts to expand that. It expands to null (internally), since there
are no array elements, which becomes the value of the parameter expansion.
Since the expansion (${!__ref}) resulted in the null string, `set -u' kicks
in and bash reports a fatal error.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/