H5diff exits with 1 but doesn't print differences


I ran h5diff on two hdf5 files and it gave no output so I thought they were identical and everything was fine. However it turns out that the two files had different groups in them so everything was not fine. Upon closer inspection, h5diff was silently exiting with exit code 1, producing no output despite there being differences. However this didn’t help me since I was at the command line not looking at exit codes, relying on the behavior described in the h5diff help documentation, which says that the default behavior is “Prints the number of differences found and where they occurred. If no differences are found, h5diff and ph5diff produce no output.” Another aspect: the documentation states that the error code 1 means “Some differences were found.” However h5diff -v, after correctly listing the group differences, reports “0 differences found” in conflict with the returned error code.

This python code followed by “h5diff f1.h5 f2.h5” reproduces the behavior:

import h5py
h5py.File(‘f1.h5’, ‘w’).create_group(‘g1’)
h5py.File(‘f2.h5’, ‘w’).create_group(‘g2’)

My expectation was that h5diff output something like diff would on directories containing different files, e.g.

Only in f1.h5: /g1
Only in f2.h5: /g2

If silently returning 1 when only group differences are found is a desired behavior, in my opinion it should be a special option, not the default behavior.

This is on a Mac 10.15.4 running h5diff version 1.12.0, the latest in homebrew (hdf5).


Try to use -v -r flags to see the differences. See h5diff documentation for more info.