From 0fcc400d0a3df96d5fbee2e4afe91942ce7bd4bc Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:10:40 -0700 Subject: [PATCH] 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). --- 1988/westley/demo.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/1988/westley/demo.sh b/1988/westley/demo.sh index b14f9975e..d2d46266c 100755 --- a/1988/westley/demo.sh +++ b/1988/westley/demo.sh @@ -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