logoalt Hacker News

aboundyesterday at 2:17 PM9 repliesview on HN

> Here’s the alphabet, in encoding order:

> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&'()+,-;=@[]^_`{}~

Yeah I definitely don't want any of those last ~22 characters in file names if I need to do anything with them from a shell


Replies

hnlmorgyesterday at 6:35 PM

I don’t see how they’re any worse than spaces in file names, which is an edge case you need to cater for already anyway.

show 4 replies
orrayesterday at 3:19 PM

Moreover, I'd be nervous about the fact that filenames on Windows tend to be case insensitive.

show 2 replies
Dwedityesterday at 2:50 PM

Even just "-" in a filename is problematic, since you can name actual files with "--" at the beginning, and the name could match a switch.

show 1 reply
dgacmuyesterday at 2:42 PM

Yeah, I'm sympathetic to their desire for compression and efficiency but base64URL is way more shell-friendly.

I quite like base58 for human-presented identifiers also. I tend to use it instead of hex for having ~8-16 character IDs of things.

show 1 reply
loukyyesterday at 6:48 PM

Same! Although I still have muscle-memory replacing spaces with _ or - when creating/saving files on any OS. Hasn't done me wrong lo these past 40 years. As for the others tailing the ASCII, no thanks.

show 1 reply
mmoossyesterday at 4:56 PM

I learned, and thought everyone else learned, that the safe characters for POSIX filenames are:

  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-
That is, the only safe non-alphanumeric characters are dash "-" and underscore "_". Period "." is also considered 'safe' but is tricky for obvious reasons and [IMHO, for the most reliability] best avoided except where necessary.

Authoritative source: POSIX.1-2024 standard, sec. 3.265 Portable Filename Character Set

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1...

show 1 reply
hn993302yesterday at 8:16 PM

If I'm choosing a filename, it's lowercase alphanumeric plus underscore. Usually not even the underscore.

brookstyesterday at 2:33 PM

What you don’t want a file named `reboot`?

raverbashingyesterday at 5:23 PM

100% this

(Also for anything that needs to work on a shell script or whatever)

I roll my eyes every time some "super secure secret generator" gives me a password with &^%#$ that I need to use on a shell script. Thanks for making my life harder I guess

"oh but you just need to escape them" Yes please be my guest trying to deal with character escape whack-a-mole

show 1 reply