I'd love to know whoever it was that thought tilde was a good character to use in backup filenames.
1) that rm had a (configurable) number of files / directories above which it'll ask you to double-check.
2) that files had a "pleasedontdelete" flag that rm would check and ask about.
For some programs (rm isn't one of them), removing the write permission is sufficient to get an interactive prompt when you try to overwrite/truncate/delete the file.
I really like OSX's current metaphor, where files that haven't been touched in a while get "locked", and must then be "unlocked" to modify them further. Phrasing it in terms of stability rather than permission makes a lot of sense to me. It's too bad the metaphor isn't echoed in the CLI.
$ touch foo
$ chmod -w foo
$ rm foo
rm: remove write-protected regular empty file ‘foo’?
There's also the immutable attribute many modern filesystems support, which prevents the file from being modified unless the attribute is removed. $ sudo chattr +i foo
$ rm foo
rm: remove write-protected regular empty file ‘foo’? y
rm: cannot remove ‘foo’: Operation not permittedIf I'm tapping a file that's been sitting there since the OS was installed and hasn't been touched since... Probably fair to ask me to confirm!
Install safe-rm; it does exactly that.
"If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands."
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm...
Warning: not yet widely implemented outside the GNU world.