mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:04:42 +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:
@@ -244,6 +244,13 @@ clean_dev_jetbrains_toolbox() {
|
|||||||
product_dirs+=("$product_dir")
|
product_dirs+=("$product_dir")
|
||||||
done < <(command find "$toolbox_root" -mindepth 1 -maxdepth 1 -type d -print0 2> /dev/null)
|
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
|
local product_dir
|
||||||
for product_dir in "${product_dirs[@]}"; do
|
for product_dir in "${product_dirs[@]}"; do
|
||||||
while IFS= read -r -d '' channel_dir; do
|
while IFS= read -r -d '' channel_dir; do
|
||||||
@@ -276,6 +283,8 @@ clean_dev_jetbrains_toolbox() {
|
|||||||
version_dirs+=("$version_dir")
|
version_dirs+=("$version_dir")
|
||||||
done < <(command find "$channel_dir" -mindepth 1 -maxdepth 1 -type d -print0 2> /dev/null)
|
done < <(command find "$channel_dir" -mindepth 1 -maxdepth 1 -type d -print0 2> /dev/null)
|
||||||
|
|
||||||
|
[[ ${#version_dirs[@]} -eq 0 ]] && continue
|
||||||
|
|
||||||
local -a sorted_dirs=()
|
local -a sorted_dirs=()
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
local dir_path="${line#* }"
|
local dir_path="${line#* }"
|
||||||
|
|||||||
Reference in New Issue
Block a user