From c9d1eac7f2ea9d83cf2b9c84c1ef925e57b4fc39 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Sep 2026 23:41:15 +0000 Subject: [PATCH] wolf: fix unbound-variable crash on a single-drive box with no unmounted disks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmed live on a laptop with only its internal drive (no second/ unmounted disk at all): the game-storage-directory picker's `local -a _UNMT_DEV _UNMT_LABEL _UNMT_UUID` declares the arrays but, when the lsblk scan finds zero qualifying unmounted block devices, never actually assigns an element to any of them. Under setup.sh's `set -u`, that's enough for a later read (`${#_UNMT_DEV[@]}`) to throw "unbound variable" even though the arrays were properly `local -a` declared — a known bash nounset quirk this repo has already hit and documented once before (see vendor/ai-stack/configure-searxng-safesearch.sh). Explicit `=()` initializers side-step it. The sibling `_CAND_*` arrays a few lines above don't need the same fix — they always get at least one element (the home directory option is unconditional), so they can't hit this path. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01VLX1yYKJExGSXmgUhxKQG6 --- services/wolf.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/wolf.sh b/services/wolf.sh index 85c6d8e..e40dd28 100644 --- a/services/wolf.sh +++ b/services/wolf.sh @@ -647,8 +647,13 @@ UDEV ((_ci++)) done < <(lsblk -Pno NAME,MOUNTPOINT,SIZE,LABEL,UUID 2>/dev/null) - # Unmounted block devices — skip disks that have any mounted partition - local -a _UNMT_DEV _UNMT_LABEL _UNMT_UUID + # Unmounted block devices — skip disks that have any mounted partition. + # Explicit =() initializers, not bare `local -a` — under setup.sh's + # `set -u`, an array that never gets an element assigned (e.g. a laptop + # with no second/unmounted drive at all) can still trip "unbound + # variable" on later reads like ${#_UNMT_DEV[@]} below, even though it + # was declared with `local -a`. Confirmed live on a single-drive laptop. + local -a _UNMT_DEV=() _UNMT_LABEL=() _UNMT_UUID=() local _ui=0 while IFS= read -r _line; do local _name _size _type _fstype _mnt _label