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.

Yes, I realize that one can use -v -r flags to get more output.

This does not correct the fact that h5diff documentation describes the default behavior as

“Prints the number of differences found and where they occurred. If no differences are found, h5diff and ph5diff produce no output.”

but h5diff does NOT do this when the files contain different groups. This is either a coding bug or a documentation error.

One of the two should be fixed. My preference is that it be fixed in the code to match the described behavior, because here I am almost one year later and I ran into the same problem again with a different set of files. :frowning:

Yes, the documentation should be updated.
H5diff was intended to show differences between data, which is the documentation indicated output.
However a file can also be different in structure, which is not indicated other then with a -v value or -r.

Allen