From d0bad95968b0ad1bda7ef694fdf5b8e7f396faa6 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 23 Dec 2025 11:26:34 +0100 Subject: posix-shell: utils: Add hexdiff() This tool outputs the diff of two hexdumps based on the two files provided as arguments. --- posix-shell/utils.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/posix-shell/utils.sh b/posix-shell/utils.sh index 4354a37..b21c09b 100644 --- a/posix-shell/utils.sh +++ b/posix-shell/utils.sh @@ -258,3 +258,21 @@ lar() { popd rm -rf "$temporary_directory" } + +hexdiff() { + if test "$#" -ne 2 + then + echo "Usage: hexdiff " + return 1 + fi + + dump1="$(mktemp)" + dump2="$(mktemp)" + + hexdump -C "$1" > "$dump1" + hexdump -C "$2" > "$dump2" + + diff --unified=4 --color=always "$dump1" "$dump2" + + rm -f "$dump1" "$dump2" +} -- cgit v1.2.3-70-g09d2