Global Variable Scope Issue in build_drive_map() #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Line ~200-210
build_drive_map() {
local host=$(hostname)
declare -A drive_map # Local associative array
}
Issue: Creating a local array then copying to global is inefficient. Should declare
DRIVE_MAP as global at the start.
Fix: Use
declare -g -A DRIVE_MAP at function start, populate directly.