Overview
zdiff runs diff on gzip-compressed files, decompressing them first, so you see the differences in the text. It takes the options of diff, such as -u, and gives the same exit status.
Background
The macOS manual describes zcmp and zdiff together, as tools to compare compressed files. Today the name covers the GNU gzip script zdiff and the zdiff on macOS. The BusyBox 1.37.0 build used for this page has no zdiff applet.
Examples
Show the differences in the default format; the status is 1 when they differ:
printf 'a\nb\n' | gzip > f.gz && printf 'a\nc\n' | gzip > g.gz && zdiff f.gz g.gz; test $? -eq 1 && echo differ
Say only whether they differ, with -q:
printf 'a\nb\n' | gzip > f.gz && printf 'a\nb\n' | gzip > h.gz && zdiff -q f.gz h.gz && echo same
Common mistakes
A status of 1 means "different", as with diff, so a script with set -e stops. The file names in a unified diff (-u) may show temporary names for the decompressed text on some systems. Compressed files that hold the same text are the same for zdiff, even if the compressed bytes differ.
Portability
This page has no BusyBox view: BusyBox has no zdiff applet. The GNU versions are shell scripts, which the implementation probe never runs, so they are not identified automatically; the Linux guest ran them anyway. The Common examples were executed on GNU gzip scripts in the Linux guest and macOS system tools (see the development guide for the exact check).
About GNU zdiff
GNU zdiff is part of GNU gzip, and it is a shell script that calls gzip.
References
Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.