Some users insist on using bash. This is a good shell, but not as good
as zsh. But, I do want them to be able to use the per directory
umask as well as all the zsh users.
So I started digging, as the bash shell does not support a chpwd
hook.
This is what I came up with:
chpwd()
{ # Set the initial umask
case "${PWD}/"
in
/etc/puppet/*)
um=$(umask)
umask 007
;;
*)
[[ x"${um}" != x"" ]] && umask ${um}
;;
esac
}
function cd()
{
builtin cd "${@}"
chpwd
}Now, when I change to the directory /etc/puppet I do get a umask of
007 and when I cd somewhere else, I do get the original umask.
I do redefine the intercal cd command to run the chpwd hook. There
must be a more elegant way to do this, but this does the job.