Abort if the cd fails.

This commit is contained in:
Wayne Davison
2011-05-07 12:58:11 -07:00
parent 58663df432
commit 8bcd6a4aff

View File

@@ -24,10 +24,12 @@ if [ "$user" ]; then
prefix=''
if [ $do_cd = y ]; then
home=`perl -e "print((getpwnam('$user'))[7])"`
prefix="cd '$home' ;"
prefix="cd '$home' &&"
fi
sudo -H -u "$user" sh -c "$prefix $*"
else
[ $do_cd = y ] && cd
if [ $do_cd = y ]; then
cd || exit 1
fi
eval "${@}"
fi