|
From: | Douglas Lewan |
Subject: | [Help-bash] Unsetting members of associative arrays |
Date: | Thu, 11 Apr 2019 12:32:04 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Icedove/52.9.1 |
The following code doesn't do what I expect. The ostensibly unset array element is still there. There's a work-around: Keep track of the indexes to unset and do that outside the loop. declare -A array for i in address@hidden ; do do if [[ ${array[${i}]} = bob ]] then unset array[${i}] fi done Is there a real reason for that or is it a bug? Thanks. -- ,Doug Douglas Lewan +1 (908) 720-7908 The trouble with the world is that the stupid are cocksure and the intelligent full of doubt. - Bertrand Russell
[Prev in Thread] | Current Thread | [Next in Thread] |