Find the system's MD5 binary.
authorWill Maier <willmaier@ml1.net>
Fri, 28 Jul 2006 13:46:19 -0500
changeset 3025 d9b8d28c0b94
parent 3024 b41cd423e5a3
child 3028 ea734528ce04
child 3029 d161e6f39557
Find the system's MD5 binary. Different binaries calculate MD5 checksums on different systems. Try a couple known programs and only calculate and verify the checksum if they exist. This should silence warnings on eg OpenBSD.
hgeditor
--- a/hgeditor	Tue Aug 29 14:04:54 2006 -0500
+++ b/hgeditor	Fri Jul 28 13:46:19 2006 -0500
@@ -41,13 +41,15 @@
 
 cat "$1" > "$HGTMP/msg"
 
-CHECKSUM=`md5sum "$HGTMP/msg"`
+MD5=$(which md5sum 2>/dev/null) || \
+    MD5=$(which md5 2>/dev/null) 
+[ -x "${MD5}" ] && CHECKSUM=`${MD5} "$HGTMP/msg"`
 if [ -s "$HGTMP/diff" ]; then
     $EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
 else
     $EDITOR "$HGTMP/msg" || exit $?
 fi
-echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && exit 13
+[ -x "${MD5}" ] && (echo "$CHECKSUM" | ${MD5} -c >/dev/null 2>&1 && exit 13)
 
 mv "$HGTMP/msg" "$1"