- Add global caching for `detect_architecture`, `get_darwin_major`, `get_optimal_parallel_jobs`, and `is_ansi_supported` to reduce subshell overhead.
- Improve robustness of `get_lsregister_path` by returning 1 on failure.
- Enhance security of `get_user_home` by replacing `eval echo` with `id -P`.
When Mole is called from GUI applications (e.g., SwiftUI apps), the
request_sudo_access() function would fail with '/dev/tty: Device not
configured' error because /dev/tty is not available in non-TTY contexts.
This commit adds automatic detection of the runtime environment and uses
macOS native password dialog (via osascript) when running in GUI mode,
while preserving all existing TTY behavior including Touch ID support.
Changes:
- Detect TTY availability before attempting terminal-based authentication
- Use osascript to display native password dialog in GUI mode
- Maintain backward compatibility with all terminal-based workflows
- Ensure secure password handling (unset after use)
Fixes commands like 'mole clean', 'mole optimize', 'mole purge' when
invoked from GUI applications.
Remove unused functions from base.sh and ui.sh:
- base.sh: is_interactive, spinner stack management, get_terminal_info, validate_terminal_environment
- ui.sh: with_spinner
Net reduction: ~166 lines of dead code
- Switch bytes_to_human (shell) and humanizeBytes (Go) from Base-2
(1024) to Base-10 (1000) to match Apple's storage calculation
standard since Snow Leopard
- Add proper decimal rounding instead of truncation
- Use mdls kMDItemLogicalSize for .app bundles to avoid APFS clone
file undercounting by du
Fixes#511
This commit addresses the issue #506 where mole would exit prematurely
during application support scanning.
Changes:
1. Remove 4 redundant pipefail disable/restore blocks:
- safe_find_delete() in lib/core/file_ops.sh
- safe_sudo_find_delete() in lib/core/file_ops.sh
- fix_broken_preferences() in lib/optimize/maintenance.sh
- opt_saved_state_cleanup() in lib/optimize/tasks.sh
These were unnecessary because process substitution (< <(cmd)) is not
affected by pipefail - only real pipelines (cmd1 | cmd2) are.
2. Fix real bug in fix_broken_preferences():
- Add || true to ((broken_count++)) on lines 35 and 55
- This prevents set -e from exiting when broken_count starts at 0
Fixes#506
Replace hardcoded 70-char string with a dynamically generated divider
capped at terminal width (max 70) so the separator fits narrow terminals
instead of overflowing them.
- Fix safe_sudo_remove early exit on error (P1)
- Fix menu filter state leakage in paginated menu (P2)
- Fix cleanup of MOLE_MENU_FILTER_NAMES in app selector (P2)
- Correct log_operation signature for memory dumps (P2)
- Apply minor formatting fixes to dev cleanup module
Optimization:
- Skip -name "*" in safe_sudo_find_delete when pattern matches everything
- Reduces unnecessary parameter passing to find command
- Improves performance for operations that scan all files
Rationale:
- find -name "*" is redundant as it matches everything by default
- Removing it reduces command overhead without changing behavior
Gradle build cache (~/.gradle/caches) is now protected by default whitelist,
similar to Maven repository. This prevents unintentional deletion of large
dependency caches that take time and bandwidth to re-download.
- Add ~/.gradle/caches/* and ~/.gradle/daemon/* to DEFAULT_WHITELIST_PATTERNS
- Remove Gradle cleanup from clean_dev_jvm() function
- Users can disable protection via 'mo clean --whitelist' if needed
Fixes#408