Skip to content

Comment on A tale of two path separators

Comments

It took me a long time to understand why colon wasn't a valid character for file names on Mac and I still find the colon separator to be the least visible these days. Finder can display paths with the forward slash separator (defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES), and yet forward slash may be used in a file name created through Finder as noted in the post, while colon cannot (which is not addressed), but creating a file in the terminal named with a colon is possible and the shell will escape it correctly in use. This file then shows up with a slash in place of the colon when viewed in Finder, and conversely the file with a slash in the name shows up in Terminal with a colon!

You still have to worry about colons on Linux; while they're valid in file and folder names, they prevent folders from being put on PATH and understood properly.

(Other characters of course cause usability problems and are potentially even a security vulnerability depending on the terminal. But they're still "valid".)

Stock macOS uses a bash or zsh shell in the terminal (depending on the OS version), so the same points of caution hold there as well.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.