Improve 2019/diels-grabsch1/try.sh

This commit is contained in:
Cody Boone Ferguson committed 2024-01-31 09:34:14 -08:00
1 parent 6285cfd883
commit 19afcc9d45
1 file changed
+17 -8
+17 -8
View File
@@ -15,34 +15,43 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ dd bs=1024 count=2048 < /dev/zero | compress > ref.Z" 1>&2
read -r -n 1 -p "Press any key to run: dd bs=1024 count=2048 < /dev/zero | compress > ref.Z: "
echo 1>&2
dd bs=1024 count=2048 < /dev/zero | compress > ref.Z
echo 1>&2
echo "$ dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z" 1>&2
read -r -n 1 -p "Press any key to run: dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z: "
echo 1>&2
dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z
echo 1>&2
echo "$ cmp ref.Z dg1.Z" 1>&2
read -r -n 1 -p "Press any key to run: cmp ref.Z dg1.Z: "
echo 1>&2
cmp ref.Z dg1.Z
echo "Exit code of: cmp ref.Z dg1.Z: $?" 1>&2
echo 1>&2
echo "$ compress < Shakespeare.txt > ref.Z" 1>&2
read -r -n 1 -p "Press any key to run: compress < Shakespeare.txt > ref.Z: "
echo 1>&2
compress < Shakespeare.txt > ref.Z
echo 1>&2
echo "$ ./prog < Shakespeare.txt > dg1.Z" 1>&2
read -r -n 1 -p "Press any key to run: ./prog < Shakespeare.txt > dg1.Z: "
echo 1>&2
./prog < Shakespeare.txt > dg1.Z
echo 1>&2
echo "Notice how the files differ:" 1>&2
echo "$ cmp ref.Z dg1.Z" 1>&2
echo "Notice how the two files differ:" 1>&2
read -r -n 1 -p "Press any key to run: cmp ref.Z dg1.Z: "
echo 1>&2
cmp ref.Z dg1.Z # Oops, the files differ
echo "Exit code of: cmp ref.Z dg1.Z: $?" 1>&2
echo 1>&2
echo "... and notice how this works fine:" 1>&2
echo "$ zcat < dg1.Z | cmp - Shakespeare.txt" 1>&2
read -r -n 1 -p "Press any key to run: zcat < dg1.Z | cmp - Shakespeare.txt: "
echo 1>&2
zcat < dg1.Z | cmp - Shakespeare.txt
echo "Exit code of zcat < dg1.Z | cmp - Shakespeare.txt: ${PIPESTATUS[1]}"
echo 1>&2
echo "What happened?"