bbhexdiff

A Command-line tool to invoke BBEdit’s Find Differences command on file hex dumps on Mac OS X.

Based upon bbdiff.

twhexdiff is a modified version of bbhexdiff tool designed to work with TextWranger instead of BBEdit. Except were noted, twhexdiff works identically to bbhexdiff.

Download

bbhexdiff (4.0 KB) Updated March 28, 2003
twhexdiff (4.0 KB) Updated February 6, 2004

Usage

bbhexdiff [-b -i -s] [-o oldhex] [-n newhex] oldfile newfile

Option

-b

Keep BBEdit in the background. By default, BBEdit will activate if differences are found.

-i

Case insensitive comparison.

-s

Ignore leading and trailing whitespace on lines.

-o oldhex

Specify a file name for the hex dump from the old file. If this option is not specified, a temporary file will be created in the /tmp directory.

-n newhex

Specify a file name for the hex dump from the new file. If this option is not specified, a temporary file will be created in the /tmp directory.

Installation

bbhexdiff is a Perl script uses the hexdump tool, AppleScript, and BBEdit. To install it, download the source code or copy and paste it into a text file with Unix-style line endings. Save the file in a location that is included in your PATH variable (I use /usr/local/bin). Modify the permissions so the file is executable, like so:

chmod 755 bbhexdiff

Notes

If your copy of BBEdit is not named “BBEdit” (as opposed to something like “BBEdit 7.0), you will need to either rename the application or modify the bbhexdiff script to reflect the different application name.

bbhexdiff uses the hexdump command-line tool because BBEdit’s Hex Dump plug-in cannot be controlled via AppleScript. If you want to modify the formatting of the hex dumps, you should modify the value of the hexdump variable. By default, bbhexdiff uses hexdump’s -C argument to create canonical hex and ASCII dumps. See the hexdump manpage for information about additional options.

Should the Hex Dump plug-in gain AppleScript support in the future, I will look into updating this script accordingly.

twhexdiff notes

If your copy of TextWrangler is not named “TextWrangler,” you will need to either rename the application or modify the twhexdiff script to reflect the different application name.

twhexdiff requires TextWrangler 1.5.1 in place of BBEdit.

Version History

1.0: Thu Mar 27, 2003
Initial release.

1.1: Fri Mar 28,

  • Fix bug so you can compare files of the same name without saving the hex files.
  • Make sure hex names are unique in all usage cases.
  • Remove debugging code for printing names of hex files with -o and -n options.
  • Correct date of 1.0 release – yesterday was not a Monday.

Copyright and License

Copyright (c) 2003 Eric Blair

bbdiff Copyright (c) 2002 John Gruber

This program is free and open software. You may use, copy, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same.