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

refactor: enhance install script robustness with improved error handling, option validation, and safer file operations, and add error checking for alias removal during uninstall.

This commit is contained in:
Tw93
2025-12-31 14:46:14 +08:00
parent e30dfd3c57
commit 108563ed9b
2 changed files with 41 additions and 115 deletions

8
mole
View File

@@ -622,9 +622,13 @@ remove_mole() {
if [[ -f "$alias" ]]; then
# Check if directory requires sudo
if [[ ! -w "$(dirname "$alias")" ]]; then
sudo rm -f "$alias" 2> /dev/null || true
if ! sudo rm -f "$alias" 2> /dev/null; then
has_error=true
fi
else
rm -f "$alias" 2> /dev/null || true
if ! rm -f "$alias" 2> /dev/null; then
has_error=true
fi
fi
fi
done