bug-bash
[Top][All Lists]
Advanced

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

Re: Empty array referenced by indirection reports unbound variable


From: Alex fxmbsw7 Ratchev
Subject: Re: Empty array referenced by indirection reports unbound variable
Date: Tue, 6 Apr 2021 15:56:53 +0200

arr=( ) implies no [0]=

On Mon, Apr 5, 2021, 22:46 konsolebox <konsolebox@gmail.com> wrote:

> 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]