Leopard ‘file’ command oddity
Apparently, Leopard changed the file
command. On Tiger, the -i
argument makes it print out mime types instead of the more human friendly descriptions it normally uses. On Leopard, this has been changed. From the man page: “If the file is a regular file do not classify its contents.” What this means is that a lot of files just get identified as “regular file” which doesn’t seem all that useful to me.
I found this change a bit reckless as it can break software using it (like a certain piece of software written by yours truly). I thought this might be a change that Apple inherited from BSD, but, doing a small survey (thanks to Tom Harrington for the FreeBSD datapoint), that may not be the case:
OS | file version |
-i behavior |
---|---|---|
Darwin/Tiger (8.11.0) | 4.10 | print mime type |
Linux (2.4.32) | 4.12 | print mime type |
Darwin/Leopard (9.1.0) | 4.17 | do not classify regular files |
FreeBSD (6.2) | 4.21 | print mime type |
In addition, according to this man page which seems to describe the same version of file
that is installed with Leopard, it also shows -i
behaving like everyone else’s version.
So, the question is, “Apple, why?” It appears there are a bunch of other letters in the alphabet available. Why cannibalize an existing one?
In the meantime, I’ll just use the equivalent --mime
option but I’m still a bit confused as to why I’m having to make this change at all. Bad Apple, no cookie for you!
Update:
Tim Buchheim points out in the comments that this new behavior is to make Darwin compliant with the Single Unix Specification. Now knowing what to search for, I dug up these release notes which list the changes (including the ones to the file
command). Good to know that there was some reason for this.
Category: OS X 3 comments »
January 2nd, 2008 at 9:32 pm
Apple’s “improvements” to
file
caused a lot of headache for me as well. They changed Mach-O “fat file” to report as “universal binary”.January 2nd, 2008 at 10:18 pm
Leopard complies with the Single Unix Specification, version 3. The SUS specification for file(1) says that -i should do what Leopard’s does.
See the wikipedia article: http://en.wikipedia.org/wiki/File_(Unix)
January 2nd, 2008 at 10:38 pm
Tim: Ah, now it finally makes sense. I’m still grumbling but at least I know it’s not arbitrary. Updating the post with the explanation.