Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Aug 2001 18:27:18 -0700 (PDT)
From:      Jeremy Chadwick <yoshi@parodius.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/29790: sed "G" command broken
Message-ID:  <200108170127.f7H1RIA18748@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         29790
>Category:       bin
>Synopsis:       sed "G" command broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 16 18:30:06 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jeremy Chadwick
>Release:        4.4-RC, and 2.2.8
>Organization:
>Environment:
FreeBSD pentarou.parodius.com 4.4-RC FreeBSD 4.4-RC #1: Wed Aug 15 23:35:36 PDT 2001     root@pentarou.parodius.com:/usr/obj/usr/src/sys/PARODIUS-SMP  i386
>Description:
The "G" command in sed does not conform to proper sed usage; command does not output a newline as stated in the manpage, nor as stated in the official sed FAQ.

This applies to ALL versions of FreeBSD (tested/verified on 2.2.8 and all 4.x revisions).  This bug more than likely applies to OpenBSD and NetBSD as well.

I'm hoping this bug can get squashed before 4.4-STABLE comes out...
>How-To-Repeat:
$ printf "1\n2\n3\n" | sed '1,2H;2G'

The output is:

1
2
1
2
3

But should be:

1
2
(blank line)
1
2
3
>Fix:
Approximately line 151 of src/usr.bin/sed/process.c:

cspace(&PS, hs, hsl, 0);

Change to:

cspace(&PS, "\n", 1, 0);
cspace(&PS, hs, hsl, 0);

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108170127.f7H1RIA18748>