If SCREENDIR is set and we sudo the directory will probably be
unusable. Unset it if SUDO_USER is defined.
# Fixup screen and define ``session'' if available.
screen=$(find_working screen 2>/dev/null)
if [ $? = 0 ]; then
- # Override SCREENDIR iff screen is not setuid.
+ # Override SCREENDIR iff screen is not setuid (but not under sudo).
if ! ls -l "$screen" | cut -d ' ' -f 1 | grep s >/dev/null; then
- export SCREENDIR="$HOME/.screen/$HOSTNAME"
+ if [ -n "$SUDO_USER" ]; then
+ unset SCREENDIR
+ else
+ export SCREENDIR="$HOME/.screen/$HOSTNAME"
+ fi
fi
krenew=$(find_working krenew 2/dev/null)