using BSD sed(1) with label treats semicolon as not delimiter, as label itself

Issue #128 resolved
Takehiko NOZAKI repo owner created an issue

try following:

$ cat >test.txt
aaa
bbb
^D
$ sed -e ':loop;N;$!b loop;s/\n//' test.txt
sed: 1: ":loop;N;$!b loop;s/\n//": unused label 'loop;N;$!b loop;s/\n//'
aaa
bbb

GNU sed is:

$ gsed -e ':loop;N;$!b loop;s/\n//' test.txt
aaabbb

this is not standard beheiver but only extension. but useful to write sed(1) one-liner.

OpenBSD already supports this:

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/compile.c#rev1.16 handle ; terminators for strings like other sed programs do. this is apparently an extension, but without it you cannot express longer labelled sed scripts as one-liners. noted by seb@todesplanet.de apr 2002. also noted by cerille lefevre a bit later. fixed by otto and myself, tested on tree builds to be careful

Comments (2)

  1. Takehiko NOZAKI reporter

    fixed, <<cset:05739bf>>

    see commit log: ENHANCEMENT: Issue #128 -- sed (1) treats semicolon as delimiter, not part of label. this patch retrive from OpenBSD:

    http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/compile.c#rev1.16 handle ; terminators for strings like other sed programs do. this is apparently an extension, but without it you cannot express longer labelled sed scripts as one-liners. noted by seb@todesplanet.de apr 2002. also noted by cerille lefevre a bit later. fixed by otto and myself, tested on tree builds to be careful

  2. Log in to comment