Timeline for Why isn't the `else` arm executed in this Bash script (for loop through an array)?
Current License: CC BY-SA 4.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 28, 2022 at 21:09 | comment | added | Gilles 'SO- stop being evil' |
@JohnSmith ${#TOGOs[@]} is the length of the array. This checks whether the array is empty.
|
|
| Jan 28, 2022 at 18:58 | comment | added | John Smith |
Thanks, your code works fine. Simply placing double quotes around ${TOGOs[@]} also solved the issue in my code. Would you decode # in if [[ ${#TOGOs[@]} -eq 0 ]]? P.S. "" is meant to be the second element of the array TOGOs.
|
|
| Jan 28, 2022 at 18:49 | vote | accept | John Smith | ||
| Jan 28, 2022 at 18:28 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 4.0 |