Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Of course, Linux could do what Solaris did decades ago and define the directory order in which `rm -rf /` works to start with `pwd` - and thus fail immediately. That would fix that problem completely.


How did they fix that, in the rm binary?

In the example above, the command would be `rm -rf /` without the variable present, and the shell would expand / to all the folders in /. So it's not a direct call to `rm -rf /`, you would need to handle the shell expansion of /* as well?


I missed the * on the end.


you can rmdir $PWD no problem. as long as there are no files in it. i guess it catches almost all cases though.

come to think of it, when would you ever want to rm -rf/? even in a chroot it doesn’t seem like a thing you’d want to do.


When working in chroot jails on embedded distributions, I have needed to run `rm -rf /`. It's admittedly really edge-casey, but it's happened.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: