patch(1) on FreeBSD does not support null bytes. With GNU diff/patch I could handle multiple files containing null bytes with one patch, but xxd (which handles null bytes) does not seem to support this. How can I generate something similar to unified diff's with the native FreeBSD toolchain?

  • Patch is for text files, why do you like to use it for binary files? – schily Nov 23 '15 at 14:34
  • Does it have to be something “inert” on which the patcher will run a simple command like patch, which doesn't risk running arbitrary code, or can you use an arbitrary script as the patch? – Gilles 'SO- stop being evil' Nov 23 '15 at 23:34

The "native FreeBSD toolchain", i.e., the base system is rather limited. You could use the ports for GNU diff/patch, or alternatively xdelta. bsdiff also is a possibility.

However, unified diffs (as the comments suggest) are specifically for text files because they are a specific format in terms of lines.

Xdelta provides the ability to generate deltas between a pair of files and later apply those deltas. It operates similar to the diff and patch commands, but works on binary files and does not produce a human readable output.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.