From 396f92f9b00a783038925f3c136a4b11bf6e2bc8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:17:57 -0800 Subject: [PATCH] Rename 2019/karns/demo.sh try.sh It was already documented as such (in the thanks file) but it was still the old name (demo.sh). The README.md had demo.sh still but this has been updated as it's all for the try section. --- 2019/karns/Makefile | 6 +++--- 2019/karns/README.md | 2 +- 2019/karns/{demo.sh => try.sh} | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) rename 2019/karns/{demo.sh => try.sh} (62%) diff --git a/2019/karns/Makefile b/2019/karns/Makefile index 6cb1f6e3f..5677b3f1d 100644 --- a/2019/karns/Makefile +++ b/2019/karns/Makefile @@ -114,7 +114,7 @@ PROG= prog # OBJ= ${PROG}.o CSRC= ${PROG}.o -DATA= maze demo.sh +DATA= maze try.sh TARGET= ${PROG} # ALT_OBJ= @@ -141,8 +141,8 @@ ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} ${LN} -sf ${PROG} tbfs -test: prog - ${CAT} prog.c | ./prog +test: ${PROG} + ./${PROG} < ${PROG}.c # alternative executable diff --git a/2019/karns/README.md b/2019/karns/README.md index df51ddeb5..257946013 100644 --- a/2019/karns/README.md +++ b/2019/karns/README.md @@ -26,7 +26,7 @@ The last two can be done in a sequence, first showing the respective files at the terminal, like: ```sh -./demo.sh +./try.sh ``` diff --git a/2019/karns/demo.sh b/2019/karns/try.sh similarity index 62% rename from 2019/karns/demo.sh rename to 2019/karns/try.sh index e70d0f521..e8e02483d 100755 --- a/2019/karns/demo.sh +++ b/2019/karns/try.sh @@ -5,8 +5,17 @@ # Doesn't run the program on README.md as it's longer and slower. # -# make prog first and exit if failure -make || exit +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear # display prog.c to the user echo "$ cat prog.c"