From daa0507b474c1ca70893451b3e83f5a2c7a1d06f Mon Sep 17 00:00:00 2001 From: Raine Date: Sun, 19 Nov 2023 01:10:55 +0100 Subject: [PATCH] fix: smart sudo --- dot | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dot b/dot index 2bb2b0f..398ca9f 100755 --- a/dot +++ b/dot @@ -19,7 +19,8 @@ include() { func() { if is_function $(echo "super_$2"); then [ "${DO_SUDO:-yes}" = "yes" ] || return 0 - sudo sh -c ". $1 && super_$2" + cmd="sh -c \". $1 && super_$2\"" + [ "$(id -u)" = "0" ] && $cmd || sudo $cmd fi is_function $2 && $2 }