kiss: Fix crash caused by sh256(). Closes #204

This commit is contained in:
Dylan Araps 2020-11-25 08:49:32 +02:00
parent 58846c99b1
commit 16b2e1be75
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 11 additions and 9 deletions

20
kiss
View File

@ -113,17 +113,19 @@ sh256() {
# All utilities must match 'sha256sum' output.
#
# Example: '<checksum> <file>'
[ -f "$1" ] || return 0
hash=$(
sha256sum "$1" ||
sha256 -r "$1" ||
openssl dgst -sha256 -r "$1" ||
shasum -a 256 "$1" ||
digest -a sha256 "$1"
)
# Skip non-files and broken symlinks.
if { [ -h "$1" ] && [ -e "$1" ] } || [ -f "$1" ]; then
hash=$(
sha256sum "$1" ||
sha256 -r "$1" ||
openssl dgst -sha256 -r "$1" ||
shasum -a 256 "$1" ||
digest -a sha256 "$1"
)
printf '%s\n' "${hash%% *}"
printf '%s\n' "${hash%% *}"
fi
}
pkg_lint() {