A tale of two path separators

(alexwlchan.net)

48 points | by dbaupp 4 days ago

6 comments

  • VorpalWay 4 hours ago
    Old Macs (which I grew up with) had even more baroque path handling than mentioned in the blog post:

    Double colon (::) meant the same as .. on Unix/DOS, that is "go up one level". So you have to be careful when concatenating paths to not get double separators.

    Paths starting with : were relative. If a path didn't start with the separator, the first component was the volume name (disk partition). Again, quite unlike Unix.

    Also, remember it was common to have spaces in names on Mac, even the default harddrive on Macs was named "Macintosh HD". So an absolute path like "Macintosh HD:Programs:MacWrite" would have been common. (I grew up with Macs in Swedish, so I'm back translating the names here, could be that the names were slightly different in English.)

    • BoingBoomTschak 3 hours ago
      Fun things is that I encountered that for the first time when using Clozure CL (https://ccl.clozure.com/) which quotes colons when converting paths to string even on Linux:

        $ cat <<'EOF' >x.lisp
        heredoc> (require :uiop)
        heredoc> (let ((p (make-pathname :name "foo:bar")))
        heredoc>   (format t "~@{~A~%~}" (namestring p) (uiop:native-namestring p)))
        heredoc> EOF
        $ ccl -b -Q -l x.lisp </dev/null
        foo\:bar
        foo:bar
        $ sbcl --script x.lisp
        foo:bar
        foo:bar
    • fragmede 4 hours ago
      Current macOS Finder let's you name files with a slash in them, rendered as a : in the terminal.
      • VorpalWay 3 hours ago
        Isn't that just what the original article that we all commented on described? I don't understand what you are trying to add to the conversation here.
      • microtonal 3 hours ago
        I think that the slash might be the rendering though? If you

            $ touch "foo:bar"
        
        In the Terminal, then Finder renders it as foo/bar.

        So who is lying, how is it stored in the directory entry in APFS itself?

  • windowliker 4 hours ago
    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!
  • pedromlsreis 1 hour ago
    I'm curious how much of this behaviour is still intentional design vs. just inertia. Are the modern filesystems still constrained by these older choices, or is it mostly for compatibility?
    • p_l 1 hour ago
      Filesystems usually do not see path separators at all, it's something handled at VFS level
      • Kwpolska 41 minutes ago
        But they do see / or : in file names, and the interesting question is which one it is today on which filesystem.
  • momoraul 1 hour ago
    Another Windows oddity: each drive letter has its own current directory. D: doesn't mean the root of D:, it means "wherever you last were on D:". Same with C:foo, which is relative to C:'s current directory. DOS baggage that's still around.
  • breppp 2 hours ago
    I was expecting the story of the magical ¥ path separator
    • petee 1 hour ago
      Would you mind sharing a related link? I'm finding it to be impossible to search "¥ path separator", the ¥ is stripped out by like every search engine even when quoted
      • Kwpolska 39 minutes ago
        The short version is, the DOS-era Japanese character sets had replaced \ with ¥, and modern Windows still shows paths as C:¥WINDOWS if you're using the Japanese locale.
  • bebe83939 2 hours ago
    Now imagine operating system, that has no directories (and no path separators) or no filesystem at all.
    • rswail 1 hour ago
      Like CP/M, DOS v1, RT-11 etc.

      VMS used:

          node::device:[dir1.dir2.dir3]filename.extension;version
      
      from memory, you could have up to 15 nested directories.

      The versioning was cool as long as you remembered to clean them up.

      • Joker_vD 25 minutes ago
        Or even just Amazon S3.