[ -d "$tmpdir" ] && rm -rf "$tmpdir" My recollection is that we explicitly cd away because we don't want to be in $tmpdir (or a subdir) when doing the rm -rf. cd "$tmpdir/.." Should be ok. However, I have also never heard before of a system where / is not readable. I'm surprised anything works.