From 536237955215d767e0472ca84391a3d14c1f5b1b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 31 Oct 2024 23:55:58 +0100 Subject: [PATCH] etc/profile.d/nb.sh --- etc/profile.d/nb.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 106e210b..5e447463 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -22,13 +22,19 @@ nb_repo_su_exec() { local usage="nb_repo_su_exec REPO_DIR COMMAND" local repo="${1:?$usage}"; shift local u=$( ls -1dl "$repo" | awk '{print $3}' ) + + local sav_pwd=${PWD:-$(pwd)} + cd "$repo" + if [ "$u" != "$USER" ]; then - sudo -i -u "$u" $@ + sudo -u "$u" $@ #return 0 else $@ #return 1 fi + + cd "$sav_pwd" } nb_repos_status() { -- 2.47.3