diff --git a/checksum.sh b/checksum.sh index 732d5a5ae..25879062b 100755 --- a/checksum.sh +++ b/checksum.sh @@ -1,15 +1,15 @@ #!/bin/bash # SPDX-License-Identifier: Apache-2.0 +set -o xtrace # This script executes a binary file, captures its output, then generates and compares its SHA-256 hash with a provided one. -output=$(./$1) -output_hash=$(echo "$output" | sha256sum | awk '{ print $1 }') +output_hash=$(./$1 | sha256sum | awk '{ print $4 }') -if [ "$output_hash" == "$2" ]; then - echo "$1 Hashes match." - exit 0 +if [[ ${output_hash} == "${2}" ]]; then + echo "${1} Hashes match." + exit 0 else - echo "$1 Hashes do not match: $output_hash vs $2" - exit 1 -fi \ No newline at end of file + echo "${1} Hashes do not match: ${output_hash} vs ${2}" + exit 1 +fi