mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
example: add output-crc32-digest flag
This commit is contained in:
1 parent
6017c37232
commit
4e20ba6876
4 files changed
+108
-39
No files matched your search
@@ -39,19 +39,9 @@ fi
|
||||
# ----
|
||||
|
||||
handle() {
|
||||
# "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
|
||||
local c=$(gen/bin/example-mzcat --output-crc32-digest <$1 2>/dev/null)
|
||||
if [ "$c" != "BAD 00000000" ]; then
|
||||
echo $c $1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -47,19 +47,9 @@ fi
|
||||
# ----
|
||||
|
||||
handle() {
|
||||
# "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
|
||||
local c=$(gen/bin/example-convert-to-nia --output-crc32-digest <$1 2>/dev/null)
|
||||
if [ "$c" != "BAD 00000000" ]; then
|
||||
echo $c $1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user