Making rm undoable

David Korn[drew] dgk at ulysses.homer.nj.att.com
Wed Mar 29 13:44:51 AEST 1989


I implemented a version of unlink(name) that did a rename() to a file with
the same name in a sub-directory called .trashcan, if this directory
exists.  I modified rm to use this unlink, and I modified rmdir to
consider a directory empty if the only thing it it was a .trashcan
directory.

This scheme has the advantage of having the link() always on the
same file system.  Also, only files that have a .trashcan subdirectory
are saved.  Thus, you can have a single rm command that works on
directories that you want files saved, and to remove trash from
the .trashcan directory.

Of course, I added a line to cron to clean out .trashcan directories
every day.



More information about the Comp.unix.wizards mailing list