ugh.book

(singke) #1
Shell Programming 157

There is another big problem as well, one that we’ve been glossing over
from the beginning. The Unix file program doesn’t work.


Date: Sat, 25 Apr 92 17:33:12 EDT
From: Alan Bawden <[email protected]>
Subject: Simple Shell Programming
To: UNIX-HATERS

WHOA! Hold on a second. Back up. You're actually proposing to
use the ‘file’ program? Everybody who wants a good laugh should
pause right now, find a Unix machine, and try typing “file *” in a
directory full of miscellaneous files.

For example, I just ran ‘file’ over a directory full of C source code—
here is a selection of the results:

arith.c: c program text
binshow.c: c program text
bintxt.c: c program text

So far, so good. But then:

crc.c: ascii text

See, ‘file’ isn’t looking at the “.c” in the filename, it’s applying some
heuristics based on an examination of the contents of the file. Appar-
ently crc.c didn’t look enough like C code—although to me it
couldn’t possibly be anything else.

gencrc.c.~4~: ascii text
gencrc.c: c program text

I guess I changed something after version 4 that made gencrc.c look
more like C...

tcfs.h.~1~: c program text
tcfs.h: ascii text

while tcfs.h looked less like C after version 1.

time.h: English text

That’s right, time.h apparently looks like English, rather than just
ascii. I wonder if ‘file’ has recognition rules for Spanish or French?
Free download pdf