1
0

sha256sum 591 B

12345678910111213141516
  1. #!/usr/bin/env bash
  2. # This file is part of the OpenADK project. OpenADK is copyrighted
  3. # material, please see the LICENCE file in the top-level directory.
  4. if [ -x /usr/bin/sha256sum ]; then
  5. /usr/bin/sha256sum "$@"
  6. elif [ -x /bin/cksum ] && [ $(echo | cksum -a sha256) = 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b ]; then
  7. # we assume the arguments are exactly "-c" or "-c -"
  8. x=$(sed 's/^\([0-9a-fA-F]*\) *\([^ ].*\)$/SHA256 (\2) = \1/' | cksum -c -a sha256)
  9. [[ $x = *FAILED* ]] && exit 1
  10. exit 0
  11. else
  12. tmp=$(mktemp -t yyy)
  13. cat - > $tmp
  14. shasum -a 256 "$@" $tmp
  15. fi