mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
fix: handle empty menu_options in mo purge to prevent unbound variable error (#547)
When no artifacts are found during scanning, `menu_options` remains an
empty array. With `set -euo pipefail` active, expanding `${menu_options[@]}`
on an empty array causes a fatal "unbound variable" error (line 1325).
Add an early-return guard after the spinner stops: if no items were found,
print a friendly "No artifacts found to purge" message and exit cleanly.
Fixes #546
This commit is contained in:
@@ -1310,6 +1310,14 @@ clean_project_artifacts() {
|
|||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
stop_inline_spinner
|
stop_inline_spinner
|
||||||
fi
|
fi
|
||||||
|
# Exit early if no artifacts were found to avoid unbound variable errors
|
||||||
|
# when expanding empty arrays with set -u active.
|
||||||
|
if [[ ${#menu_options[@]} -eq 0 ]]; then
|
||||||
|
echo ""
|
||||||
|
echo -e "${GRAY}No artifacts found to purge${NC}"
|
||||||
|
printf '\n'
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
# Set global vars for selector
|
# Set global vars for selector
|
||||||
export PURGE_CATEGORY_SIZES=$(
|
export PURGE_CATEGORY_SIZES=$(
|
||||||
IFS=,
|
IFS=,
|
||||||
|
|||||||
Reference in New Issue
Block a user