bug-bash
[Top][All Lists]
Advanced

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

Empty array referenced by indirection reports unbound variable


From: konsolebox
Subject: Empty array referenced by indirection reports unbound variable
Date: Tue, 6 Apr 2021 04:45:59 +0800

set -u
array=()
__ref=array[@]
: "${array[@]}" # Reports nothing
: "${!__ref}" # Unbound variable

Using bash version 5.1.4. I know this can be avoided by using namerefs
instead but indirection is more portable when no assignment is needed
and this sometimes allows my portable functions to have less versions.

The detection of unbound variables seem to have become more reasonable
since 5.0 and I hope it gets improved further.  I don't use set -u in
older bash and it's only for development mode.

-- 
konsolebox



reply via email to

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