From a83f467e4c16b1ed1c960f3d89e2472d9639477c Mon Sep 17 00:00:00 2001 From: Vince Date: Mon, 25 May 2026 13:19:29 +0800 Subject: [PATCH] Update lib-core.sh --- libs/lib-core.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/lib-core.sh b/libs/lib-core.sh index 526f9716..7c007e52 100755 --- a/libs/lib-core.sh +++ b/libs/lib-core.sh @@ -744,6 +744,18 @@ sudo() { udo() { local result="0" + if [[ "$(id -un)" == "${MY_USERNAME}" ]]; then + if [[ -p /dev/stdin ]]; then + "${@}" < /dev/stdin || result="${?}" + else + "${@}" || result="${?}" + fi + + [[ "${result}" != "0" ]] && MACTAHOE_COMMAND="${*}" + + return "${result}" + fi + # Just in case. We put the prompt here to make it less annoying if ! ${SUDO_BIN} -u "${MY_USERNAME}" -n true &> /dev/null; then prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as user"