3 ms·
A number of people have commented that they’ve never experienced a filename with `\n`, or other weird characters, in the wild. On the contrary, I’ve seen this m
by Xophmeister 2y ago
A number of people have commented that they’ve never experienced a filename with `\n`, or other weird characters, in the wild. On the contrary, I’ve seen this many many times, to the point that I’m defensive about how I write scripts, to compensate.
In my case, these were files created by some other program that contained a bug, where the filename was accidentally set to something like the file contents, say. These other programs were often written by researchers, rather than engineers, who (reasonably so) cared more about their research, than functional correctness. They were also not incentivised to clean-up the dodgy files, if they fix the bug — a big if! — or may not have even be equipped to do so.
You could argue that this is an edge case, but shit happens. Often.
- SkyPuncher 2y agoAnytime files, file systems, or binary files become involved I immediately assume everything is going to be harder and longer than estimated. There are simply so many dumb things that can happen. A library might handle 99% of cases correctly, but that 1% case basically requires an entire rewrite.
- Log_out_ 2y agoOf the filenames. Got FileRenamer CRON job, go and kill filenames. Dont solve edge cases, blunt edges at the bleeding edge. Im not gonna rewrite my software to acomodate down sign errors of the ancients.
- ykonstant 2y agoNot an edge case at all; to add another source of such file names, academics often copy-paste or manually type pdf titles into file names resulting in files with newlines. Sometimes their machines use ancient encodings which, together with non-ASCII author names and "helpful" encoding converters result in garbage file names. I've mentioned these situations before in this forum; the last time I did, I got the absurd reply "I don't care what your academic colleagues do" from someone who supposedly had sysadmin experience. So yeah, all you can do is write correct code and accept the fact that many others will refuse to.