This is an archive of the discontinued LLVM Phabricator instance.

Use md5 -q for HashProgramOutput.sh, to show only the checksum.
ClosedPublic

Authored by dim on Jul 8 2020, 10:25 AM.

Details

Summary

This option is supported on both BSDs and macOS, and ensures the command
also works if GNU coreutils are not installed.

Event Timeline

dim created this revision.Jul 8 2020, 10:25 AM
HashProgramOutput.sh
23

Why no silencing that one too?

dim abandoned this revision.Jul 31 2020, 2:54 AM
dim added inline comments.
HashProgramOutput.sh
23

With the BSD (and macOS) md5 command, the -q option is not really "silencing", but it prints out only the checksum in that case:

-q      Quiet mode - only the checksum is printed out.  Overrides the -r option.

GNU coreutils md5sum does not have an equivalent option: you must always parse the standard output, and take the first printed field as the checksum.

Note that GNU md5sum indeed has a --quiet option, but its meaning is rather different: it can only be used in --check mode, and then its effect is that it does not show OK for each correctly verified input file.

dim reclaimed this revision.Jul 31 2020, 3:09 AM
HashProgramOutput.sh
23

Then your change will make md5sum fail when the GNU version is used? I must be missing something :-)

dim added inline comments.Jul 31 2020, 6:11 AM
HashProgramOutput.sh
23

Yes, you are missing that I didn't change anything for GNU md5sum, only for the BSD/mac md5 command. :) Normally its output is something like:

% md5 foo
MD5 (foo) = d3b07384d113edec49eaa6238ad5ff00

but that makes it more difficult to parse out just the checksum. This is what the -q option is for.

serge-sans-paille added inline comments.
HashProgramOutput.sh
23

Got it! Thanks for the clarification, LGTM then :-)

This revision is now accepted and ready to land.Jul 31 2020, 7:55 AM
dim closed this revision.Aug 1 2020, 6:36 AM