13

While I'm reading file(1) I noticed this in the man page (emphasis mine):

When adding local definitions to /etc/magic, make sure to preserve these keywords. Users depend on knowing that all the readable files in a directory have the word “text” printed. Don't do as Berkeley did and change “shell commands text” to “shell script”.

What's the story behind this sentence? I guess Berkeley refers to BSD (Berkeley software distribution) but Google didn't give enough information about this.

Link to file(1) http://man7.org/linux/man-pages/man1/file.1.html

Some digging around shows that this statement was added 27 years ago link

Don't do as one computer vendor did \- change ``shell commands text''
to ``shell script''.

and later changed to current statement link

Don't do as Berkeley did \- change ``shell commands text''
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
yegle
  • 1,129
  • 1
  • 8
  • 12

2 Answers2

8

People had been writing scripts (and possibly C programs) to run file on a file, capturing the output with $(file foobar) or popen(), and doing a string match check to see whether the output from file contained (or ended with) the word “text”.  Then the developers of the Berkeley Software Distribution (at the University of California, Berkeley) did as described and caused all those scripts and programs not to recognize shell script files as text files.

  • 1
    When was this happened? Any reference? – yegle Feb 28 '14 at 01:20
  • 1
    It was probably in the late (very late) 1970s or the early 1980s. I can’t find a reference; I’m relaying my memory. – Scott - Слава Україні Mar 01 '14 at 21:50
  • `not to recognize shell script files as text files`. shell script can contain binary data:) see: [Failing detection of shell scripts with embedded binary data](http://mx.gw.com/pipermail/file/2014/001380.html), [buggy magic: #!/bin/sh with embedded binary data reported as 'data'](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707014), [Fix](https://github.com/file/file/commit/cf617ae866acbe976ebb301714799becc79f8de4) – Evgeny Vereshchagin Jul 11 '15 at 22:14
  • @EvgenyVereshchagin: OK, that's sort of relevant to the topic — but not much.  Or are you making a point? – Scott - Слава Україні Jul 17 '15 at 01:28
1

Apparently this happened between 4.2 and 4.3BSD -- compare http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/usr.bin/file.c and http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD/usr/src/usr.bin/file.c

sendmoreinfo
  • 2,533
  • 21
  • 36