Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix,net.bugs.v7,net.bugs.2bsd,net.bugs.4bsd,net.bugs.usg Subject: Re: "sed" question - undocumented features like comments Message-ID: <3011@sun.uucp> Date: Tue, 19-Nov-85 20:20:55 EST Article-I.D.: sun.3011 Posted: Tue Nov 19 20:20:55 1985 Date-Received: Thu, 21-Nov-85 03:21:25 EST References: <1238@wucs.UUCP> <748@rtech.UUCP> <3003@sun.uucp> Distribution: na Organization: Sun Microsystems, Inc. Lines: 33 Xref: sun net.unix:5968 net.bugs.v7:79 net.bugs.2bsd:194 net.bugs.4bsd:1687 net.bugs.usg:375 > 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. I checked up on it and -- good grief, they *were* that sloppy. It turns out that the S5 "sed" we're running here has the Berkeley comment code stuck in. The change is trivial; change line 171 of "sed0.c" (or thereabouts; it's line 171 in the S5R2V1 VAX distribution) from if(*cp == '\0') continue; to if(*cp == '\0' || *cp == '#') continue; Your line numbers may differ on V7, S3, other S5's, etc.. Note that 1) if you continue a command on multiple lines using \, "#" at the beginning of those continuation lines will NOT be treated as a comment indicator, and 2) "#" in the middle of a command (i.e., not at the beginning of a line or separated from the beginning of the line only by whitespace) will also not be treated as a comment indicator. This is a feature; it means that old scripts won't break by virtue of "#" characters which used to be legitimate parts of commands suddenly becoming comments.... Also note that, even in "sed"s without this code, you shouldn't have the first line of a script be a comment which immediately follows the "#" and begins with a lower-case "n" unless you want the script always to be run as if "sed" had been invoked with the "-n" flag. If the first two characters of a script are "#n", it turns on the "-n" flag, as mentioned before... Guy Harris