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
A commit references this bug: Author: dumbbell Date: Fri Aug 8 17:29:02 UTC 2014 New revision: 269729 URL: http://svnweb.freebsd.org/changeset/base/269729 Log: sed(1): Don't force a newline on last line, if input stream doesn't have one While here, change how we check if the current line is the last one. Before, we just checked if there were more files after the current one. Now, we check the actual content of those files: they files may not have a line at all. This matches the definition of the "last line" by the Open Group. The new behavior is closer to GNU sed. PR: 160745 Phabric: https://phabric.freebsd.org/D431 Reviewed by: jilles Approved by: jilles Exp-run by: antoine Changes: head/usr.bin/sed/defs.h head/usr.bin/sed/main.c head/usr.bin/sed/process.c head/usr.bin/sed/tests/regress.y.out
Committed in 11-CURRENT.