Comment lines in the Bourne shell

Paul S. R. Chisholm psc at lzwi.UUCP
Fri Jun 14 04:17:48 AEST 1985


< Smokey the Bar says, "Help stamp out software pirates" [squish!] >

In article <1194 at uwmacc.UUCP>, jwp at uwmacc.UUCP writes:
> I've noticed that on my system (2.8BSD) the Bourne shell
> comment character doesn't do what I expected.  The shell
> still looks at some characters on the line, even though
> the line is commented out.  For example, the comment
>	: to use this file type <name> | lpr
> produces a message referring to the pipe, even though the whole
> line is commented out.  What am I missing?

The colon is *NOT* a comment character.  Instead, it's a builtin
command, like cd, which happens to do nothing.  Filenames are
expanded, and quotes must be matched.  (The favorite Unix(tm)
trivia question of a friend of mine, mtgzz!ecl, is, "What does
the following do?"
	: " This is a comment
	nroff -mm lots-o-stuff
	: " Gee, that nroff ran fast!
This is one colon command, whose first argument goes from the first
to the second quote, inclusive.)

More recent versions of the Bourne shell *do* have a comment character:
"A word beginning with # causes that word and all the following
characters up to a new-line to be ignored."
---
Unix is a trademark of some entity withing AT&T, but I'm not sure what
its name is this week.  "AT&T's Bell Laboratories", maybe??
-- 
       -Paul S. R. Chisholm       The above opinions are my own,
       {pegasus,vax135}!lzwi!psc  not necessarily those of any
       {mtgzz,ihnp4}!lznv!psc     telecommunications company.



More information about the Comp.unix mailing list