aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/aurremove15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/aurremove b/bin/aurremove
index a1fc201..8487088 100755
--- a/bin/aurremove
+++ b/bin/aurremove
@@ -2,6 +2,18 @@
set -e
+function command_exists {
+ command -v $1 &> /dev/null
+}
+
+if [ ${UID} -ne 0 ]; then
+ if command_exists doas; then
+ SUDO="doas"
+ elif command_exists sudo; then
+ SUDO="sudo"
+ fi
+fi
+
# Get all arguments excluding the lastone
ARGSLEN=$(($#-1))
ARGS=${@:1:${ARGSLEN}}
@@ -10,4 +22,7 @@ ARGS=${@:1:${ARGSLEN}}
for LAST; do true; done
pacman -R ${ARGS} ${LAST}
+
+# Need write permissions to delete without root privileges
+chmod -R u+w ~/aur/${LAST}
rm -rf ~/aur/${LAST}