On Tue, Dec 22, 2009 at 02:32:24AM +0000, Matthew Szudzik wrote: > On Mon, Dec 21, 2009 at 08:37:06PM -0500, Hugo Villeneuve wrote: > > OpenBSD's sed technicaly supports command concatation with ";" on > > the command line but it breaks "branch" without label. Which correctly
I should have left more quoted text about tutorial from other sed implementation. I had been using gnu sed for a while and encountered this issue going with OpenBSD. > > Read the caveat at the end of the sed man page: > > "The use of semicolons to separate multiple commands is not permitted > for the following commands: a, b, c, i, r, t, w, :, and #." I should read better. Since it's documented, it's not a bug. Of course that sentence is false. ":" correctly interpret semicolon as next command. "b" and "t" has partial support (only when the label is not empty). It is true for the a c i r w #. Is this one of those few case where I should obey the man page rather than the code? > > Either use newlines instead of semicolons, or give each line of the > script separately with the -e option. For example, instead of > > sed 's/a/b/ ; t ; s/c/d/' > > use > > sed -e 's/a/b/' -e 't' -e 's/c/d/' It's a cute work around. My point is: if a label can't contain semicolons, why support "tlabel;" and not "t;"? I don't understand the logic of it. Don't trust this diff but it make my few test works: Index: compile.c =================================================================== RCS file: /cvs/src/usr.bin/sed/compile.c,v retrieving revision 1.28 diff -u -r1.28 compile.c --- compile.c 16 Oct 2008 16:34:32 -0000 1.28 +++ compile.c 25 Dec 2009 17:46:49 -0000 @@ -283,7 +283,7 @@ case BRANCH: /* b t */ p++; EATSPACE(); - if (*p == '\0') + if (*p == '\0' || *p == ';' ) cmd->t = NULL; else cmd->t = duptoeol(p, "branch", &p);