v2v: tests: isolate SHA1 calculation in an own shared function

sha1sum(1) does not exist everywhere, so wrap it in an own function so
the right implementation can be chosen on each OS.  Also, wrapping it
avoid using awk everytime.
This commit is contained in:
Pino Toscano
2016-03-18 15:03:22 +01:00
parent 41795a1c98
commit 8aee5726d3
5 changed files with 27 additions and 6 deletions

View File

@@ -28,3 +28,16 @@ do_md5 ()
;;
esac
}
do_sha1 ()
{
case "$(uname)" in
Linux)
sha1sum "$1" | awk '{print $1}'
;;
*)
echo "$0: unknown method to calculate SHA1 of file on $(uname)"
exit 1
;;
esac
}