Do you have a experience that you remove some files or directories accidentally? In that case, our rm(1) safety expansion feature would be nice.
Patch for FreeBSD 9-current.
Patch for FreeBSD 7-current.
prompt 3.1 shows how to apply the patch and install.
# cd /usr/src/bin/rm/
# patch < /anywhere/rm.c.diff-20070925
# make obj depend && make && make install
# make clean
The patch gives rm(1) an ability to add specific option for all files and directories under specific directory automatically and any deeply. That aims to prevent removing some files or directories accidentally. Patched rm(1) reads ${HOME}/.rm file as configuration file that owner just has write permission. If other user has write permission of ${HOME}/.rm, patched rm(1) cannot allow "-f" option.
By following ${HOME}/.rm file, patched rm(1) use '-i' option to all files that has any depthes under /bin, /boot, /etc, /root, /sbin, /var and /usr excluding /var/db/pkg, /var/tmp, /usr/local and /usr/ports. A "-" means non-option.
# ${HOME}/.rm: rm(1) configuration file
#
# options directory
i /bin
i /boot
i /etc
i /root
i /sbin
- /var/db/pkg
- /var/tmp
i /var
- /usr/local
- /usr/ports
i /usr
Have attention of directory order in ${HOME}/.rm file. It is under first-matching rule. So most times you should write subdirectories before parent directory. Well, a directory written in ${HOME}/.rm file is not targeted itself.
Have attention, too. The end line "/" of directory in ${HOME}/.rm file means something special. If you do not read source code of that patch, do not attach "/" end of directory. This strange behavior will be changes in near future. And directory must be absolute path. Patched rm(1) compares absolute path if it is symbolic link or not.
If you attach "-f" on command line, patched rm(1) does not read ${HOME}/.rm file.