From a79fc4e2266cc84b9fca46bfe101fbe066a7b0af Mon Sep 17 00:00:00 2001 From: Duc Tri Nguyen Date: Sun, 14 Apr 2024 15:40:01 -0400 Subject: [PATCH] forward output to pipe directly Signed-off-by: Duc Tri Nguyen --- checksum.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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