commit: 2bb3c6940c3000924d145515832797ae5bf29f31
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue May 3 09:31:08 2016 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue May 3 09:31:08 2016 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=2bb3c694
scripts/startprefix: retain some more useful env vars
scripts/startprefix.in | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/scripts/startprefix.in b/scripts/startprefix.in
index aafd04d..861f02d 100644
--- a/scripts/startprefix.in
+++ b/scripts/startprefix.in
@@ -37,9 +37,15 @@ fi
# give a small notice
echo "Entering Gentoo Prefix ${EPREFIX}"
# start the login shell, clean the entire environment but what's needed
+RETAIN="HOME=$HOME TERM=$TERM USER=$USER SHELL=$SHELL"
# PROFILEREAD is necessary on SUSE not to wipe the env on shell start
-[[ -n ${PROFILEREAD} ]] && DOPROFILEREAD="PROFILEREAD=${PROFILEREAD}"
-env -i HOME=$HOME TERM=$TERM USER=$USER SHELL=$SHELL $DOPROFILEREAD $SHELL -l
+[[ -n ${PROFILEREAD} ]] && RETAIN+=" PROFILEREAD=$PROFILEREAD"
+# ssh-agent is handy to keep, of if set, inherit it
+[[ -n ${SSH_AUTH_SOCK} ]] && RETAIN+=" SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
+# if we're on some X terminal, makes sense to inherit that too
+[[ -n ${DISPLAY} ]] && RETAIN+=" DISPLAY=$DISPLAY"
+# do it!
+env -i $RETAIN $SHELL -l
# and leave a message when we exit... the shell might return non-zero
# without having real problems, so don't send alarming messages about
# that