Subject: bug#26002: [patch] md5sum --digest-only

From: Pádraig Brady <[email-masked]>
Date: Mon, 6 Mar 2017 20:26:07 -0800

On 05/03/17 23:55, Michael Vogt wrote:
> Hi,
> 
> this is a bit of a RFC (anlong with a patch). I would like to have an
> option in md5sum (and friends) that displays only the digest without
> the filename. The use-case is mostly package maintainer scripts. They
> often need the md5sum to e.g. check if a conffile has changed and use
> patterns like:
> 
>   `md5sum /etc/papersize 2> /dev/null | awk '{print $1}'`
>   `md5sum /etc/lsb-release | cut -d" " -f1`
>   $(md5sum /etc/networks | sed -e 's/ .*//')
> 
> Having a --digest-only option in md5sum would make this a bit more
> uniform.
> 
> Attached is a small patch, if the suggestion gets accepted I'm happy
> to flesh it out more and write the man-page entry and tests.

This is one of those marginal ones, previously discussed as indicated at:
https://www.gnu.org/software/coreutils/rejected_requests.html#checksum

Note your forms above don't handle the case where a leading '\'
is added for certain edge case filenames.
The most general solution would be something like:

  md5sum < the_file | cut -f1 -d' '

I suppose you could avoid the new option and behave like wc.
I.E. don't print the extraneous '-' at all.
That would also be backwards compat with all the processing forms above.
Though not forwards compat, in that new scripts running against
older versions of md5sum would now not work.

Given the minimal/obvious processing involved,
I'm still slightly in favor for leaving as is.

thanks,
Pádraig