Date: Tue, 11 May 2010 22:27:22 +0300 From: Eitan Adler <lists@eitanadler.com> To: vogelke+unix@pobox.com Cc: freebsd-questions@freebsd.org, David Allen <the.real.david.allen@gmail.com> Subject: Re: md5(1) and cal(1) Message-ID: <AANLkTimXdqm_MQqViaHQxsH8K3yQ_B3R2UTRZOYNzLhK@mail.gmail.com> In-Reply-To: <20100511175621.4B861BE5F@bsd118.wpafb.af.mil> References: <AANLkTil779I9T4JhvaHgCCYkbSTz4xoqzjGv6wYVpYaR@mail.gmail.com> <20100511175621.4B861BE5F@bsd118.wpafb.af.mil>
next in thread | previous in thread | raw e-mail | index | archive | help
--e0cb4e887e21f2af110486568423 Content-Type: text/plain; charset=UTF-8 > D> 2. Why doesn't md5(1) have a "check" option? Seems to me requiring a > D> manual inspection is error-prone at best, and makes scripting > D> unecessarily complicated. > Would something like the attached patch be good? It adds a -c option for a string to check against. It prints "[failed]" if the string does not match the files md5 unless in -q mode. It also returns 2 to indicate md5 match failure for use in scripts. --e0cb4e887e21f2af110486568423 Content-Type: application/octet-stream; name="md5-check.patch" Content-Disposition: attachment; filename="md5-check.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g9345t3k0 SW5kZXg6IG1kNS4xCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIG1kNS4xCShyZXZpc2lvbiAyMDc0MzMpCisrKyBt ZDUuMQkod29ya2luZyBjb3B5KQpAQCAtNzMsNiArNzMsOCBAQAogVGhlIGhleGFkZWNpbWFsIGNo ZWNrc3VtIG9mIGVhY2ggZmlsZSBsaXN0ZWQgb24gdGhlIGNvbW1hbmQgbGluZSBpcyBwcmludGVk CiBhZnRlciB0aGUgb3B0aW9ucyBhcmUgcHJvY2Vzc2VkLgogLkJsIC10YWcgLXdpZHRoIGluZGVu dAorLkl0IEZsIGMgQXIgc3RyaW5nCitDb21wYXJlIGZpbGVzIHRvIHRoaXMgbWQ1IHN0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message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimXdqm_MQqViaHQxsH8K3yQ_B3R2UTRZOYNzLhK>