From nobody@FreeBSD.org  Thu Sep 15 01:42:49 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6529B106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Sep 2011 01:42:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 540668FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Sep 2011 01:42:49 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p8F1gn7h085349
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Sep 2011 01:42:49 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p8F1gnxA085340;
	Thu, 15 Sep 2011 01:42:49 GMT
	(envelope-from nobody)
Message-Id: <201109150142.p8F1gnxA085340@red.freebsd.org>
Date: Thu, 15 Sep 2011 01:42:49 GMT
From: "Wojciech A. Koszek" <wkoszek@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sed(1) appends '\n' at the end of binary data (unlike gsed(1))
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         160745
>Category:       bin
>Synopsis:       sed(1) appends '\n' at the end of binary data (unlike gsed(1))
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 15 01:50:05 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Wojciech A. Koszek
>Release:        8.2-STABLE
>Organization:
FreeBSD Project
>Environment:
FreeBSD  8.2-STABLE FreeBSD 8.2-STABLE #0: Tue Sep 13 21:31:11 CET 2011     root@:/usr/src/sys/i386/compile/GENERIC  i386

>Description:
File has ASCII data followed by binary data.

ASCII data contains lines. Binary data contains 0's and follows.

I use sed(1) to delete lines and present me the rest of the content in
untouched form. In other words: I want to get binary data streamed
throught sed(1) without modification.

Currently sed(1) appends '\n' at the end of such data.

gsed(1) works as expected.

While gsed(1) just pipes binary data without a problem, we
pipe data, but append '\n' at the end.
>How-To-Repeat:
Install ports/textproc/gsed for comparison.

Run:
http://freebsd.czest.pl/~wkoszek/stuff/freebsd/sed_problem.sh

Script below.

#!/bin/sh

echo 1 > data
echo 2 >> data
echo 3 >> data
dd if=/dev/zero bs=1m count=1 >> data
echo "========== WE ========="
cat data | sed '1,3 d' | hexdump -c | tail -5
echo "========== GNU ========"
cat data | gsed '1,3 d' | hexdump -c | tail -5

>Fix:


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