I have a directory /usr/local/foo, which I need to remove. This is going to be part of a script, which needs to be run as root. I'm mainly worried that the directory, which contains things that users can edit, could contain something that causes a simple "rm -rf /usr/local/foo" to accidentally delete other things. For example, if they managed to symlink foo to point to /dev or something and rm followed it.
I would like the directory gone, along with whatever is in it. This includes user files, symlinks, and everything else. However, I would like it to not delete /dev if some malicious user has symlinked foo to /dev.
System: Ubuntu and FreeBSD and OSX
rmwill always delete the actual contents of the folder only. It will only remove a symlink itself, never the contents that the symlink points to.