3 ms·
The only forbidden characters in a Unix filenames are '/' and '\0' Want to mess with such a script? $ touch "$(echo -e -n 'lol\nposix')"
by pixdamix 9y ago
The only forbidden characters in a Unix filenames are '/' and '\0'
Want to mess with such a script?
$ touch "$(echo -e -n 'lol\nposix')"
- hnlmorg 9y agoIndeed. This is one of the reasons why I wrote a shell that handles file names as JSON strings. However for normal day to day usage, file names with \n are rare while files with spaces in their name are common. So returning an array of space delimited file names is a potentially dangerous practice for common scenarios where as find's default behaviour is only dangerous for weird and uncommon edge cases. (And if you think those are a likely issue then you probably shouldn't be doing your file handling inside a POSIX shell in the first place).
- majewsky 9y agoOne of the cruelest things you can do is a filename that consists only of a combining diacritic (without a glyph that it could combine with). Will break outputs of various programs (starting with ls) in sometimes hilarious ways. If you're trying it out now and cannot figure out how to delete it: "ls -li" to find the file's inode number, then `find -inum $INODE_NUMBER -delete`.
- anowlcalledjosh 9y agoWow, that's really horrible. I have a file sitting around with a couple of newlines in the name just so I can see how many programs don't cope with it, but I hadn't thought of using a lone combining diacritic. If anyone wants a command to make one, try touch $'\U035F' (using U+035F COMBINING DOUBLE MACRON BELOW for no particular reason, see [1] for more) [1]: https://en.wikipedia.org/wiki/Combining_Diacritical_Marks https://en.wikipedia.org/wiki/Combining_Diacritical_Marks