about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPiraty <piraty1@inbox.ru>2021-05-01 19:11:21 +0200
committerLeah Neukirchen <leah@vuxu.org>2021-05-01 19:18:41 +0200
commit343ee924455eb56b6bf3c798e4d7c87cf6921972 (patch)
tree344684ce23d7bb24c30bed25c3e3427e8adc04b8
parent6c535297595416409e185089a715b6c34748ea2d (diff)
downloadxtools-343ee924455eb56b6bf3c798e4d7c87cf6921972.tar.gz
xtools-343ee924455eb56b6bf3c798e4d7c87cf6921972.tar.xz
xtools-343ee924455eb56b6bf3c798e4d7c87cf6921972.zip
xi: don't use sudo/doas if uid is 0
Closes: #208 [via git-merge-pr]
-rwxr-xr-xxi6
1 files changed, 4 insertions, 2 deletions
diff --git a/xi b/xi
index df328f1..6a8c648 100755
--- a/xi
+++ b/xi
@@ -27,11 +27,13 @@ if BRANCH=$(git symbolic-ref -q --short HEAD 2>/dev/null) && [ -n "$BRANCH" ]; t
 fi
 
 which_sudo() {
-	if command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-install; then
+	if [ "$(id -u)" = "0" ]; then
+		return
+	elif command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-install; then
 		echo sudo
 	elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
 		echo doas
-	elif [ "$(id -u)" != 0 ]; then
+	else
 		echo su
 	fi
 }