using forward slash in unix filenames

Mar 31, 2009

Ok, I was automating the creation of some ogg files based on title's appearing in a text file. Doing it myself, with mplayer and oggenc, I hadn't taken into account many of the caveats that preexisting ripping/encoding tools take care of, like the problem of forward slashes in filenames stored on a unix filesystem. But the good thing with doing it yourself is that you don't have to automatically adopt the presuppositions that appear in preexisting tools.

One such presupposition is that you have to replace special characters in filenames, like quotes or forward slashes, so that they can be accessible to shell users. Well I have to say that shells and file managers are pretty advanced these days and you don't really have to replace anything anymore. The only exception is forward slashes, which absolutely cannot appear in a filename on a unix system. Most tools replace the slash with an underscore character. I find that kind of lame.

In Unicode, forward slash is the character 'SOLIDUS' (U+002F), although according to wikipedia, calling the http://en.wikipedia.org/wiki/Slash_(punctuation) 'solidus' "contradicts long-established English typesetting terminology".

So, since replacement of the slash is required in filenames, we can keep the visual nature of the forward slash by using the typographic solidus character as a replacement, which in unicode is called 'SOLIDUS' (U+002F). Here is the difference between the two (in the typeface your browser is using):

Slash (U+002f) Solidus (U+2044)

In VIM you can input the solidus by typing Ctrl+V, u, 2044 in command mode.