bug#81541: Script-breaking changes to "sum" command
Collin Funk <[email protected]> Sun, 02 Aug 2026 21:57:56 -0700
| Newsgroups | gmane.comp.gnu.core-utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
"Fine, Thomas" via GNU coreutils Bug Reports <[email protected]> writes: > At some point between 8.3 and 9.5, the behavior of the sum command changed. > > It used to not print the filename, when only one file was checked. > Now it always prints the filename no matter what. > > Scripts which compare checksums of individual files are now broken because > they don't expect to see a filename there, and therefore the checksums of > two different files no longer match. > > This is breaking scripts. It should have been added as an option for the > future to preserve script behavior, but, failing that, at least an option > should have been added to make for a trivial fix for scripts. It was changed in 9.0. The decision was not mine, but I feel that the rationale is sound. Here is the NEWS entry: sum [-r] will output a file name, even if only a single name is passed. This is consistent with sum -s, cksum, and other sum(1) implementations. That is, your script would be broken on NetBSD, DragonFlyBSD, FreeBSD, macOS, and Solaris anyways. There are likely others that I am unfortunately not able to test. Regarding your scripts, you can have them use the following instead: $ sum < /dev/null 00000 0 Alternatively, you can use 'cksum' which supports much better algorithms which are less likely to have hash collisions. Collin