Groesbeek, view of the 'National Liberation Museum 1944-1945' in Groesbeek. © Ton Kersten
Fork me on GitHub

umask per directory

2010-12-08 (83) by Ton Kersten, tagged as linux, puppet, sysadm

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:

{   # Set the initial umask
    case "${PWD}/"
            umask 007
            [[ x"${um}" != x"" ]] && umask ${um}
function cd()
    builtin cd "${@}"

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.