script: have print-*-checksums.sh show exit codes

This commit is contained in:
Nigel Tao committed 2023-12-26 22:21:13 +11:00
1 parent cf927b20bf
commit 5a7299b5c2
10 files changed
+753 -719

No files matched your search

+13 -3
View File
@@ -39,9 +39,19 @@ fi
# ----
handle() {
local c=$(gen/bin/example-mzcat <$1 2>/dev/null | gen/bin/example-crc32)
if [ "$c" != "00000000" ]; then
echo $c $1
# "Use $x for the exit code" is loosely based on
# https://stackoverflow.com/a/16530815
local x
local o=$(((((gen/bin/example-mzcat <$1 2>/dev/null; echo $? >&3) |\
gen/bin/example-crc32 >&4) 3>&1) | (read x; echo $x)) 4>&1)
local a=($o)
# ${a[0]} holds the exit code of gen/bin/example-etc.
# ${a[1]} holds the CRC-32 hash of gen/bin/example-etc's output.
if [ ${a[0]} == 0 ]; then
echo OK. ${a[1]} $1
elif [ ${a[1]} != "00000000" ]; then
echo BAD ${a[1]} $1
fi
}
+13 -3
View File
@@ -47,9 +47,19 @@ fi
# ----
handle() {
local c=$(gen/bin/example-convert-to-nia <$1 2>/dev/null | gen/bin/example-crc32)
if [ "$c" != "00000000" ]; then
echo $c $1
# "Use $x for the exit code" is loosely based on
# https://stackoverflow.com/a/16530815
local x
local o=$(((((gen/bin/example-convert-to-nia <$1 2>/dev/null; echo $? >&3) |\
gen/bin/example-crc32 >&4) 3>&1) | (read x; echo $x)) 4>&1)
local a=($o)
# ${a[0]} holds the exit code of gen/bin/example-etc.
# ${a[1]} holds the CRC-32 hash of gen/bin/example-etc's output.
if [ ${a[0]} == 0 ]; then
echo OK. ${a[1]} $1
elif [ ${a[1]} != "00000000" ]; then
echo BAD ${a[1]} $1
fi
}