[TUHS] # (was Re: sh: cmd | >file)

Brian Walden tuhs at cuzuco.com
Mon Jan 6 16:30:07 AEST 2020


A bit more on this.
csh(1) was wrtten around 1978 and yes # as a comment was only for
scrtipts, think it was why would you need to comment interactively?
And the # as an addition to be a comment in Bourne shell had to be around 1980
as that is when Dennis Ritchie added #! to exec(2) in the kernel. From this
point on this forced all UNIX scripting languages to use # as a comment as
it just exec'd the first string after the #! with the name of the current
file being exec'd as the single argument. So things like perl(1) and python(1)
had to use # if they wanted the #! mechanism to work for them too.

So this worked great for shell scripts, it didn't work for awk(1) nor sed(1)
nor s(1)(that is R(1) now) scripts (all needed a -f for input from file)
nor dc(1) scripts as dc had no comment character.
While Research UNIX got !# in 1980, this was after the 7th Edition release
and the 8th Edition wasn't released until 1985), BSD got it around 1982-83,
and System V didn't implement it until 1988. Eventully #! was extented
so #!/usr/bin/awk -f would work.

Also Bill Joy was the first to use # as a comment character in an /etc config
file for his /etc/ttycap (which became /etc/termcap) for vi(1). Most configs
did not have a comment at all at that time, while /etc/master used a * as a
comment (SCCS used * as a comment too btw)

Also before you say wait! ALGOL uses # as comment and is older than
Kernighan' ratfor(1). This is a later addition. The original used the EBCDIC
cent sign character to start and another cent sign to end the comment
(i.e. programmer's two cents). If you were on an ASCII system this became
"co" (for comment) as the original ASCII does not have a cent sign

-Brian


More information about the TUHS mailing list