Skip to content

Commit

Permalink
forward output to pipe directly
Browse files Browse the repository at this point in the history
Signed-off-by: Duc Tri Nguyen <[email protected]>
  • Loading branch information
cothan committed Apr 14, 2024
1 parent 6ba15c6 commit a79fc4e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions checksum.sh
Original file line number Diff line number Diff line change
@@ -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
echo "${1} Hashes do not match: ${output_hash} vs ${2}"
exit 1
fi

0 comments on commit a79fc4e

Please sign in to comment.