From e54d77893aea2109f79a96e8c4ab076995075c09 Mon Sep 17 00:00:00 2001 From: Jeremy McClure Date: Fri, 17 Jul 2026 06:32:12 -0400 Subject: [PATCH] docker-stacks-update: fix --list freeze + unbound variable - Add missing 'shift' in --list case (caused infinite loop) - Initialize color vars to empty strings before tput block (set -u errored when tput unavailable or non-TTY) --- docker-stacks-update/docker-stacks-update.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker-stacks-update/docker-stacks-update.sh b/docker-stacks-update/docker-stacks-update.sh index cc89c16..f3b26ef 100755 --- a/docker-stacks-update/docker-stacks-update.sh +++ b/docker-stacks-update/docker-stacks-update.sh @@ -10,6 +10,7 @@ set -euo pipefail # ── Terminal colours ────────────────────────────────────────────── +BOLD=""; RED=""; GREEN=""; YELLOW=""; CYAN=""; RESET="" if command -v tput >/dev/null 2>&1 && [ -t 1 ]; then BOLD=$(tput bold 2>/dev/null || true) RED=$(tput setaf 1 2>/dev/null || true) @@ -21,6 +22,7 @@ fi # ── State ─────────────────────────────────────────────────────────── TARGET_STACKS=() # user-specified stacks (empty = all) +LIST_ONLY=false # --list flag all_names=() # pre-filter stack names (for error messages) updated_names=() # stack names that were updated updated_detail=() # parallel: "stack: service1, service2" @@ -45,6 +47,7 @@ that have updates. Options: -h, --help Show this help message + -l, --list List running stacks and exit -s, --stack Target a specific stack (repeatable) No options = update all running stacks. @@ -56,6 +59,7 @@ EOF while [[ $# -gt 0 ]]; do case "$1" in -h|--help) usage ;; + -l|--list) LIST_ONLY=true; shift ;; -s|--stack) shift [[ $# -eq 0 ]] && { echo -e " ${RED}✗${RESET} Option --stack requires a name." >&2; exit 1; } @@ -103,6 +107,10 @@ for name in "${names[@]}"; do done echo "" +if $LIST_ONLY; then + exit 0 +fi + # ── Spinner for long operations ───────────────────────────────────── _spin_kill=""