Mercurial > hg > toybox
changeset 1335:d90f692a50d4 draft
Make md5sum/sha1sum -b flag be "brief" output (just the hash).
(It's not like systems implementing -b binary and -t text still matter.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 07 Jun 2014 10:42:20 -0500 |
parents | 9fd2bcedbeb5 |
children | 97c7f42068b5 |
files | toys/lsb/md5sum.c |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/lsb/md5sum.c Tue Jun 03 06:27:24 2014 -0500 +++ b/toys/lsb/md5sum.c Sat Jun 07 10:42:20 2014 -0500 @@ -8,8 +8,8 @@ * They're combined this way to share infrastructure, and because md5sum is * and LSB standard command, sha1sum is just a good idea. -USE_MD5SUM(NEWTOY(md5sum, NULL, TOYFLAG_USR|TOYFLAG_BIN)) -USE_MD5SUM_SHA1SUM(OLDTOY(sha1sum, md5sum, NULL, TOYFLAG_USR|TOYFLAG_BIN)) +USE_MD5SUM(NEWTOY(md5sum, "b", TOYFLAG_USR|TOYFLAG_BIN)) +USE_MD5SUM_SHA1SUM(OLDTOY(sha1sum, md5sum, "b", TOYFLAG_USR|TOYFLAG_BIN)) config MD5SUM bool "md5sum" @@ -21,6 +21,8 @@ Output one hash (16 hex digits) for each input file, followed by filename. + -b brief (hash only, no filename) + config MD5SUM_SHA1SUM bool "sha1sum" default y @@ -28,9 +30,11 @@ help usage: sha1sum [FILE]... - calculate sha1 hash for each input file, reading from stdin if one. + calculate sha1 hash for each input file, reading from stdin if none. Output one hash (20 hex digits) for each input file, followed by filename. + + -b brief (hash only, no filename) */ #define FOR_md5sum @@ -230,7 +234,7 @@ // Wipe variables. Cryptographer paranoia. memset(&TT, 0, sizeof(TT)); - printf(" %s\n", name); + printf((toys.optflags & FLAG_b) ? "\n" : " %s\n", name); } void md5sum_main(void)