Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am having trouble finding this information, and trial and error is telling me that there may not be any. So I figured I ask the community to see if anyone knows and can point me to a apple page that confirms if Lion as any characters that would be invalid for a file name or directory name.

share|improve this question

migrated from stackoverflow.com Aug 21 '11 at 20:29

This question came from our site for professional and enthusiast programmers.

1  
Single forward slash ? Single backslash ? Single or double period ? –  koan Aug 21 '11 at 19:35
    
All the slash combo's and singles seem to work, but a single and double period do fail because they are already in use. I hope there is more than that.... :) –  Rodney Foley Aug 21 '11 at 19:43
    
You can't use an ASCII NUL. Think a while and you might spot why yourself… –  Donal Fellows Aug 21 '11 at 19:45
    
@Donal ASCII NUL is not something you can easily just "type" or do problematically by mistake. –  Rodney Foley Aug 21 '11 at 19:48
1  
Can you give us some context, Rodney? It would help a lot in answering this if we understood a little bit about what you're trying to do... AFAIK, there are a few potential issues: honest-to-god forbidden characters, characters that are impossible to enter as a path in a terminal shell, and characters that won't display properly in Finder. –  Shog9 Aug 21 '11 at 20:03
show 4 more comments

3 Answers

up vote 3 down vote accepted

The restrictions of HFS Plus are "Unicode, any character, including NUL. OS APIs may limit some characters for legacy reasons"

share|improve this answer
2  
Techincally the HFS+ file system does allows all Unicode characters (since it represents names internally as Pascal strings with a 2-byte length), but AFAIK none of the APIs provided by OS X allow you create/open files with a slash '/' or NUL '\0' in them. –  Adam Rosenfield Aug 21 '11 at 20:54
    
APIs as in Carbon or Cocoa? I assume Terminal is under such restrictions, but what about scripts run by other programs, such as launchd? –  tobylane Aug 21 '11 at 20:58
add comment

Mac OS X Lion: What are invalid characters for a file name?

wiki HFS+:

Allowed characters in filenames Unicode, any character, including NUL. OS APIs may limit some characters for legacy reasons


Finder doesn't currently allow entering colons in in file names, but it does allow entering backslashes. However the characters shown as slashes in Finder are shown as colons in shells, and vice versa. Finder doesn't allow any ASCII control characters either.


Bash seemed to allow all control characters except \000 (NUL). I tested it by running the output from:

for i in {1..31} 127 0; do echo touch \\$(bc <<< "obase=8;$i"); done
share|improve this answer
add comment

EDITED

According to Wikipedia, the only invalid character is the forward-slash /, but at the UNIX layer.

share|improve this answer
1  
Maybe : is prohibited on Mac OS Classic, but certainly not on Mac OS X—touch foo:bar works perfectly fine. –  Adam Rosenfield Aug 21 '11 at 20:56
1  
Answer has been updated. You're welcome to remove your downvote. –  user3463 Aug 21 '11 at 21:38
2  
@Adam: : is valid in the “unix layer”, but it is translated to/from / in the “Mac layers” (i.e. Finder, most file-related dialogs, etc.): the colon is used as the separator in “HFS paths” and the slash is used as the separator in “POSIX paths” so there is a two-way translation depending on which “layer” you are working with. –  Chris Johnsen Aug 22 '11 at 4:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.