Improve 1988/westley/demo.sh

Check for executable 'westley' before compiling and only _after_
compilation (if necessary) is the source shown. This way if it's
already done (as likely the case) the result of the program will be
shown closer to the source code which is entirely the point. But even if
it's not already compiled since it's compiled first it'll have the
result closer to the source (if it fails though it'll not show the
source at all).
This commit is contained in:
Cody Boone Ferguson committed 2023-10-18 14:12:13 -07:00
1 parent ea4d040925
commit 0fcc400d0a
1 file changed
+6 -4
+6 -4
View File
@@ -1,14 +1,16 @@
#!/usr/bin/env bash
clear
if [[ ! -x "westley" ]]; then
echo "$ cc westley.c -o westley"
cc -std=gnu89 -Wno-error -Wno-implicit-function-declaration -Wno-return-type -O3 westley.c -o westley || exit 1
fi
echo "$ cat westley.c"
cat westley.c
sleep 1
echo "$ cc westley.c -o westley"
cc -std=gnu89 -Wno-error -Wno-implicit-function-declaration -Wno-return-type -O3 westley.c -o westley || exit 1
echo "$ ./westley"
./westley