From 61723e8d863f00ff0109ba31322daffcbb03a848 Mon Sep 17 00:00:00 2001 From: TomP0 <35064639+TomP0@users.noreply.github.com> Date: Mon, 26 Jan 2026 02:47:08 +0000 Subject: [PATCH] fix: handle empty arrays in clean_dev_jetbrains_toolbox (#361) Add checks for empty product_dirs and version_dirs arrays before iterating to prevent "unbound variable" errors when running with set -u (pipefail) and the JetBrains Toolbox directory doesn't exist or contains no products. --- lib/clean/dev.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/clean/dev.sh b/lib/clean/dev.sh index 3904706..464d649 100644 --- a/lib/clean/dev.sh +++ b/lib/clean/dev.sh @@ -244,6 +244,13 @@ clean_dev_jetbrains_toolbox() { product_dirs+=("$product_dir") done < <(command find "$toolbox_root" -mindepth 1 -maxdepth 1 -type d -print0 2> /dev/null) + if [[ ${#product_dirs[@]} -eq 0 ]]; then + if [[ "$whitelist_overridden" == "true" ]]; then + WHITELIST_PATTERNS=("${original_whitelist[@]}") + fi + return 0 + fi + local product_dir for product_dir in "${product_dirs[@]}"; do while IFS= read -r -d '' channel_dir; do @@ -276,6 +283,8 @@ clean_dev_jetbrains_toolbox() { version_dirs+=("$version_dir") done < <(command find "$channel_dir" -mindepth 1 -maxdepth 1 -type d -print0 2> /dev/null) + [[ ${#version_dirs[@]} -eq 0 ]] && continue + local -a sorted_dirs=() while IFS= read -r line; do local dir_path="${line#* }"