at-compat: Add diff workaround for DOS/Windows hosts.
[dxcommon.git] / t / md5.sh
blob0f3395e8bb30fabaf38811d366ab2feef698dfeb
1 #!/bin/sh
3 # Copyright © 2021 Nick Bowler
5 # Fake md5sum-like program for testing the md5 detection macro.
7 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
8 # This is free software: you are free to do what the fuck you want to.
9 # There is NO WARRANTY, to the extent permitted by law.
11 : "${MD5_NO_R=}"
12 : "${MD5_HASH=d41d8cd98f00b204e9800998ecf8427e}"
13 : "${MD5_DIRECTION=forward}"
15 stdin=true
17 print_hash () {
18 case $MD5_DIRECTION in
19 forward) printf '%s %s\n' "$MD5_HASH" "$1" ;;
20 reverse) printf '%s = %s\n' "$1" "$MD5_HASH" ;;
21 *) printf 'invalid direction %s\n' "$MD5_DIRECTION" 1>&2; exit 1 ;;
22 esac
25 for arg
27 case $arg in
28 -r)
29 test x"$MD5_NO_R" = x"" || exit
30 MD5_DIRECTION=forward
31 continue ;;
32 md5)
33 continue ;;
34 esac
36 stdin=false
37 print_hash $arg
38 done
40 if $stdin; then
41 cat >/dev/null
42 print_hash stdin