aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2022-09-04 16:08:38 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2022-09-04 16:08:38 +0200
commit918cf38a62295f7b15fd47de117375b0d6ea4e77 (patch)
tree4684a7912ad75ec294a409a91b26fd9c2bb40134
parentc73b3258ba836f7555638a9f6e7efabe96f5fc3a (diff)
Fix aurremove to delete repo
-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}