== The somewhat apocryphal history of comments in the Bourne shell (This is the story as I heard it and learned it in the past. It may or may not be actually accurate, but then a lot of Unix history is passed around as folklore, and in some ways the folklore is more important and more influential than the truth.) In the beginning, in V7, the Bourne shell didn't actually have comments. Instead, all it had was _:_, which is [[not quite a comment BourneTwoComments]] (you can see this for yourself in the [[V7 sh manpage http://minnie.tuhs.org/UnixTree/V7/usr/man/man1/sh.1.html]]). As part of V7's minimalism, the kernel had no mechanism to execute shell scripts; instead, the shell did that itself when the kernel's _exec()_ refused to run an executable file. When people at Berkeley created _csh_ they gave it actual comments, introduced by _#_ characters. Having two shells created a dilemma, though; when _csh_ went to run a shell script, how would it know which shell the script was written for? The solution was simple. Since the Bourne shell didn't have _#_ comments, _csh_ could look at the start of the file; if it had a _#_, it was a _csh_ script, and otherwise it was a Bourne shell script. (Hence you at least used to be able to find some very, very old Bourne shell scripts that started '_: this is a sh script_' or the like.) Shortly after that the people at UCB came to their senses and invented '_#!_', which makes the kernel _exec()_ mechanisms directly handle shell scripts. In order to make Bourne shell scripts compatible with this new mechanism, BSD added support for _#_ comments to the Bourne shell. For backwards compatibility, they left support for the old 'executed directly by the shell when _exec()_ fails' form of shell scripts in both _csh_ and _sh_, complete with _csh_'s special peeking for '_#_' and '_:_' (where it lingers on even today). I am not sure when _#_ made it into the System V version of the Bourne shell, although I think that it didn't take too long, possibly because it was seen as a generally sensible idea given _:_'s defects as a general comment mechanism. (I believe that kernel support for '_#!_' took much longer and thus you couldn't use a shell script as a user login shell on System V machines for quite a while.) === Sidebar: an amusing experiment Put the following in an executable file and try to run it from within various shells (with eg '_sh -c /tmp/exper_') on various systems: > # > for i in 1; do > echo bourne-like shell > done Now, change the first line from '_#_' to '_:_' and try the experiment again. (This is not the only example of [[Unix fossilization UnixFossilizationExample]].)