[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed on binary files

From: Eric Blake
Subject: sed on binary files
Date: Wed, 01 Oct 2008 20:51:58 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080914 Thunderbird/ Mnenhy/

Hash: SHA1

Is there any portable way to process files that contain NUL bytes?  I'm
working on making m4 1.6 transparently handle NUL, and want to
post-process the output to normalize error messages while still verifying
that NUL bytes appeared where expected on stderr.  But on Solaris, the
native sed strips NUL bytes before processing the line (NUL bytes cannot
appear in text files, and POSIX does not define behavior on non-text
files, so this is not a bug, just a difference from GNU diff).  As a
result, the m4 testsuite either fails (if I only postprocess the captured
stderr and not the expected error) or can have false positives (if both
stderr and expected error are normalized, then regressions involving added
or missing NUL are not detected).  I don't want to require perl for just
this one test; m4 seems fundamental enough to keep the testsuite
restricted to the GNU coding standards set of tools.  The Solaris man
pages mention that /usr/xpg4/bin/tr can handle NUL bytes, but not
/usr/bin/tr; maybe I could search for an adequate tr, and change all NUL
to some other byte that does not otherwise appear in my expected output
(with the added benefit that diff might not give up early with the
complaint that the files are binary), but I don't know if that is portable
either.  Any suggestions?  Is this worth documenting in the autoconf manual?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Mozilla -


reply via email to

[Prev in Thread] Current Thread [Next in Thread]