]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/nb.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 31 Oct 2024 22:55:58 +0000 (23:55 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 31 Oct 2024 22:55:58 +0000 (23:55 +0100)
etc/profile.d/nb.sh

index 106e210b4efb6d9e071b3d0e0913740e79cb8d38..5e44746389bb664e6f45e5b73d6e9cb97d43eb5e 100644 (file)
@@ -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() {