1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 14:26:46 +00:00

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.
This commit is contained in:
TomP0
2026-01-26 02:47:08 +00:00
committed by tw93
parent 5a29f506dc
commit 61723e8d86

View File

@@ -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#* }"