Hacker News new | past | comments | ask | show | jobs | submit login

Preventing certain characters in filenames would solve a lot of issues, from security issues to wasted time all around.

But for whatever reason, when it is suggested, you get many people chiming in that "filenames should be dumb bytes, anything allowed except / !"




>But for whatever reason, when it is suggested, you get many people chiming in that "filenames should be dumb bytes, anything allowed except / !"

I guess the issue is not what filenames should be, but what filenames are. In general, when interacting with files, you have to expect everything but `/` and nullbyte. Even if you forbid it on your machine, someone may mount a NFS drive and open you to the world of weird filenames. And you never know who uses your code.

And the unicode itself is weird anyway - for example you may have normalised and denormalised names which may be the same or different string depending on how you look at them[1]. And I hope you are not planning to restrict filenames to some anglocentric [a-z0-9_- ]*, because the world is much larger and you can't pretend unicode doesn't exist.

[1] https://eclecticlight.co/2017/04/06/apfs-is-currently-unusab... and many other cases


I've put a file in my home directory named the entirety of your comment, newline included. Unfortunately I had to trim "except / !" to bring it to 255 characters.

Now at least when some tool or pipeline blows up horribly, it'll be hilarious.


Latest POSIX "encourages" implementations to forbid using newlines in pathnames.

https://austingroupbugs.net/view.php?id=251




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

Search: