←back to thread

279 points the_why_of_y | 2 comments | | HN request time: 0s | source
Show context
devit ◴[] No.11153593[source]
It seems to me that the real issue is that "rm -rf" should by default not recurse into mounted filesystems, but should at most try to unmount them.

In addition to clearing EFI variables, the current behavior will also attempt to clear any mounted removable drives and any mounted network drives, which is usually even more harmful than messing with EFI.

Of course that would be a backwards incompatible change, although I don't think many scripts rely on this behavior.

replies(2): >>11153654 #>>11156040 #
Etzos ◴[] No.11153654[source]
To be fair "rm -rf /" doesn't just work. You have to confirm that you really do want to delete everything. Destroying / in itself is pretty harmful. If you're planning to do that you should already know not to have anything you want to keep mounted.
replies(1): >>11153871 #
protomyth ◴[] No.11153871[source]
For the few use cases where a system admin wants to "rm -rf /", there are hundreds of bad scripts that can screw up a system. I believe Solaris did the right thing and made it not work.

https://www.youtube.com/watch?v=l6XQUciI-Sc&t=81m

replies(1): >>11154309 #
Etzos ◴[] No.11154309[source]
To be clear, the problem described in the video is not something that can happen. "rm -rf $1/$2" where $1 and $2 aren't defined (therefore making it "rm -rf /") will not run. If you really want to destroy your root directory you have to specify the --no-preserve-root flag. No more accidents from scripts that assume things poorly, but it will still do exactly what the user asks. 
replies(3): >>11154365 #>>11154900 #>>11155021 #
protomyth ◴[] No.11154365[source]
Yet, I can still delete my home directory by accident (e.g. Steam patch). The idea that any rm can kill the directory I'm in is just bad. A flag on rm is the wrong solution. It should just fail.
replies(2): >>11154462 #>>11154476 #
1. ambrice ◴[] No.11154462[source]
So you're saying they should remove the -r option entirely from rm?
replies(1): >>11154499 #
2. protomyth ◴[] No.11154499[source]
No, I'm saying that delete the current directory I am in is bad (as in non-standard behavior) and should not be allowed.

Asking if I want -r removed has nothing to do with anything.