Timeline for How to test if a variable is defined at all in Bash prior to version 4.2 with the nounset shell option?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 22, 2018 at 13:09 | comment | added | Florian Heigl | only works if your scripts are running with undefined variables allowed (no set -u) | |
| Jun 15, 2015 at 2:00 | comment | added | Ron Burk | This works great, so long as you want to test whether it has a value, not whether it's been defined. I.e., foobar="" will then report that foobar is unset. No wait, I take that back. Really only tests if first element is empty or not, so it seems to be only a good idea if you know the variable is NOT an array, and you only care about emptiness, not definedness. | |
| Apr 17, 2013 at 9:22 | comment | added | Stein Inge Morisbak | Had to remove [@] if array has more than one value. | |
| Apr 17, 2013 at 9:21 | history | edited | Stein Inge Morisbak | CC BY-SA 3.0 | deleted 6 characters in body |
| Apr 17, 2013 at 9:07 | history | edited | Thor | CC BY-SA 3.0 | Added code formatting |
| S Apr 17, 2013 at 8:56 | review | Late answers | |||
| Apr 17, 2013 at 9:07 | |||||
| S Apr 17, 2013 at 8:56 | review | First posts | |||
| Apr 17, 2013 at 8:57 | |||||
| Apr 17, 2013 at 8:38 | history | answered | Stein Inge Morisbak | CC BY-SA 3.0 |