aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/cli.nix b/cli.nix
index 2fa39eb..8218ebd 100644
--- a/cli.nix
+++ b/cli.nix
@@ -5,11 +5,13 @@ in
pkgs.writeShellScriptBin "pia" ''
ID=$(${pkgs.coreutils}/bin/id -u)
- if [ "$ID" -ne 0 ]; then
- if [ -x $(command -v doas) ]; then
+ if [ "$EUID" -ne 0 ]; then
+ if which doas >/dev/null 2>&1; then
exec doas "$0" "$@"
- else
+ elif which sudo >/dev/null 2>&1; then
exec sudo "$0" "$@"
+ else
+ echo "error: neither doas nor sudo found" >&2
fi
fi