4 ms·
From reddit: > It's actually rm -rf /bin. > Seems to be caused by the same reason as the famous Steam bug - using an undefined variable. Plus the default bash
by LyndsySimon 10y ago
From reddit:
> It's actually rm -rf /bin.
> Seems to be caused by the same reason as the famous Steam bug - using an undefined variable. Plus the default bash behavior that simply ignores the fact that it doesn't exist and treats it like an empty string.
> tl;dr flamebait: The Unix way™ of "everything is just text" strikes again. (EDIT: yes this a gross over-generalization)
source: https://www.reddit.com/r/programming/comments/610z2f/858521_diasporacommon_does_rm_rf_on_purge/dfauurn/ https://www.reddit.com/r/programming/comments/610z2f/858521_...
- megous 10y agoCreating the same bug in a code tree editor would certainly not help anything.
- thinkmoore 10y agoI think the alternative being suggested is that rm shouldn't accept a string that magically can reference anything in the filesystem... In our capability-based shell scripting language Shill (shill-lang.org) for example, you could prevent this sort of bug by giving the script a capability for just the diaspora_home directory, and deriving the child directories from that capability. (Of course, you still need to make sure you pass in the right directory in the first place.)
- tremon 10y agoI think the alternative being suggested is that rm shouldn't accept a string that magically can reference anything in the filesystem... That suggestion fails to grasp the basics of Unix shells however: parameter expansion as well as globbing is performed by the shell, rm "sees" nothing but fully-expanded paths.
- rwmj 10y agoCoreutils 'rm' has a --preserve-root option (the default) which does exactly this. https://www.gnu.org/software/coreutils/manual/html_node/Treating-_002f-specially.html https://www.gnu.org/software/coreutils/manual/html_node/Trea...
- Ericson2314 10y agoA language with more rigor about path concatenation (and undefined variables) would. (Yes set -e, but it's little used for better or worse.)
- comex 10y agoIndeed. When you write "$foo/bin", you're looking for a specific operation: get the path "bin" relative to the directory $foo. Ideally this should be expressed in such a way that even if $foo somehow acquires a null or "default" value (which hopefully requires more than just naming an undefined variable, as in bash), you get an error trying to lookup relative to null, rather than the slash silently turning into the root directory.
- deleted 10y ago[deleted]