3 ms·
Filenames can have newlines. If you had it as a string data structure you wouldn't have bad parsing assumptions people make like files contain no spaces (most
by cma 6y ago
Filenames can have newlines. If you had it as a string data structure you wouldn't have bad parsing assumptions people make like files contain no spaces (most realize they can), files contain no newlines (many don't know they can), a file named '-rf' doesn't ever exist in the current working directory (many people may not realize `rm *` may recursively forcibly delete lots of things under a directory).
- samatman 6y agohah, I made a related mistake once: I had intended to move something from `file` to `~file`, and moved it to `-file` instead. This breaks a remarkable number of things! I just deleted it from Finder, then remembered I could `rm '-file'`.
- eMSF 6y agoTyping those single quotes in a shell won't make any difference as far as rm is concerned (because it won't ever see them). However, some rm utilities are smart enough to remove files, even if they resemble non-existing options. For others, the idiom is (either) "rm -- -file" or (preferably) "rm ./-file" although you can combine the both of them.
- mr_toad 6y agoNewlines in file names screw up so many things (both on the command line and in visual output) that I think that anyone using them should just stop.