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 »

3 Responses to “Leopard ‘file’ command oddity”

  1. Ankur

    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”.

  2. Tim Buchheim

    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)

  3. mr_noodle

    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.


Leave a Reply



Back to top