"sed" question - undocumented features like comments

Guy Harris guy at sun.uucp
Mon Nov 18 06:37:51 AEST 1985


> 	The System V version of "sed" allows the first line of a
> script to begin with a '#'; the line is treated as a comment.  The
> 4.2 BSD "sed" allows as many such lines as you care to sprinkle
> throughout your script.

Gee, I tried running a script with multiple lines of comments sprinkled
throughout it on the 4.2 and S5 "sed"s and they both worked exactly the
same...  First *line*?  I don't believe anybody'd be so sloppy as to require
all comments to fit into *one* line.

If you check the code, you see that the "fcomp" routine in "sed0.c" has two
places where it checks for a '#'; one at the beginning of "fcomp" (the
routine that parses the command list), which checks for "#n" at the front of
the script (this causes "sed" to act as if you'd specified the "-n" flag),
and one in the body of the loop that reads the script that checks whether
*any* line in the script has a "#", possibly preceded by white space, in it.
This code is essentially the same in both (probably all) versions of "sed",
so their behavior will be identical.

(Oh boy, another undocumented feature.  Will the appropriate people please
pick this up and document them?  I've already mailed it to Berkeley and to
our local documentation people.)

	Guy Harris



More information about the Comp.bugs.2bsd mailing list