bug-bash
[Top][All Lists]
Advanced

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

Re: [Bash 4.4.5] Variable indirection, error on empty variable


From: Otenba
Subject: Re: [Bash 4.4.5] Variable indirection, error on empty variable
Date: Mon, 28 Nov 2016 04:03:01 -0500

>It is indeed an error to attempt to perform indirection on an empty or unset parameter.
What I showed was that it is an error only for an empty parameter. If it's unset then it will do what it did in Bash 4.3, which is return an empty string without error.

And another possibility is if the indirect variable has a string that is not a variable. That, right now, also returns an empty string without error.

$ indirect=
$ [[ ${!indirect} == 1 || 1 == 1 ]] && echo yes
-bash: : bad substitution
$ indirect=notavariable
$ [[ ${!indirect} == 1 || 1 == 1 ]] && echo yes
yes
$ unset indirect
$ [[ ${!indirect} == 1 || 1 == 1 ]] && echo yes
yes

In my opinion, in all three cases variable indirection should errorlessly return an empty string.

reply via email to

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