mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 20:54:50 +00:00
fix: improve dry-run mode and error handling
- Export MOLE_DRY_RUN env var for subprocess visibility - Add || true to grep commands to prevent pipeline failures - Add dry-run test for clean_orphaned_system_services - Simplify clean_local_snapshots tests
This commit is contained in:
@@ -295,7 +295,7 @@ clean_local_snapshots() {
|
||||
[[ -z "$snapshot_list" ]] && return 0
|
||||
|
||||
local snapshot_count
|
||||
snapshot_count=$(echo "$snapshot_list" | grep -Eo 'com\.apple\.TimeMachine\.[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}' | wc -l | awk '{print $1}')
|
||||
snapshot_count=$(echo "$snapshot_list" | { grep -Eo 'com\.apple\.TimeMachine\.[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}' || true; } | wc -l | awk '{print $1}')
|
||||
if [[ "$snapshot_count" =~ ^[0-9]+$ && "$snapshot_count" -gt 0 ]]; then
|
||||
echo -e " ${YELLOW}${ICON_WARNING}${NC} Time Machine local snapshots: ${GREEN}${snapshot_count}${NC}${GRAY}, Review: tmutil listlocalsnapshots /${NC}"
|
||||
note_activity
|
||||
|
||||
@@ -667,7 +667,7 @@ check_large_file_candidates() {
|
||||
local snapshot_list snapshot_count
|
||||
snapshot_list=$(run_with_timeout 3 tmutil listlocalsnapshots / 2> /dev/null || true)
|
||||
if [[ -n "$snapshot_list" ]]; then
|
||||
snapshot_count=$(echo "$snapshot_list" | grep -Eo 'com\.apple\.TimeMachine\.[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}' | wc -l | awk '{print $1}')
|
||||
snapshot_count=$(echo "$snapshot_list" | { grep -Eo 'com\.apple\.TimeMachine\.[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}' || true; } | wc -l | awk '{print $1}')
|
||||
if [[ "$snapshot_count" =~ ^[0-9]+$ && "$snapshot_count" -gt 0 ]]; then
|
||||
echo -e " ${YELLOW}${ICON_WARNING}${NC} Time Machine local snapshots: ${GREEN}${snapshot_count}${NC}${GRAY}, Review: tmutil listlocalsnapshots /${NC}"
|
||||
found_any=true
|
||||
|
||||
Reference in New Issue
Block a user