From db6b154b70e5ef837cababcf0b1f4799df3f33e1 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 20 Oct 2023 05:58:08 -0700 Subject: [PATCH] Fix 1989/jar.2 There were some things unclear in the README.md file that have now been corrected. Clarified in the README.md that running make clobber all will run the program itself. The make alt target now runs the alt code just like the entry itself. This is fine because it is a simulation (to avoid annoyance of writing binary data to /dev/tty) and since one may still run the program or script directly it's fine. The alternate code section in the README.md was cleaned up and formatted as well. --- 1989/jar.1/Makefile | 4 +++- 1989/jar.1/README.md | 21 +++++++++++++++------ 1989/jar.1/jar.1.alt.sh | 9 ++++++++- 1989/jar.1/jar.1.sh | 9 ++++++++- thanks-for-fixes.md | 17 ++++++++++++++++- 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/1989/jar.1/Makefile b/1989/jar.1/Makefile index a553faf19..fc13b9f65 100644 --- a/1989/jar.1/Makefile +++ b/1989/jar.1/Makefile @@ -140,10 +140,12 @@ alt: data ${ALT_TARGET} @${TRUE} ${PROG}.alt: ${PROG}.alt.c - @echo "NOTE: The original source might not compile using modern compilers." + @echo NOTE: this compilation results in running the program itself. ${RM} -f $@ ${CP} jar.1.alt.sh $@ ${CHMOD} +x $@ + @echo NOTE: We will now simulate: ${CC} -c -o /dev/tty jar.1.alt.c + ${CC} -c -o /dev/stdout jar.1.alt.c 2>/dev/null | ${STRINGS} # data files # diff --git a/1989/jar.1/README.md b/1989/jar.1/README.md index 1bd4c1cb3..691a352ea 100644 --- a/1989/jar.1/README.md +++ b/1989/jar.1/README.md @@ -9,36 +9,45 @@ Finland ## To build: +NOTE: this will run the program itself. + ```sh make clobber all ``` +There is an alternate version with a slight difference. See [Alternate +code](#alternate-code) below. + ## To run: +NOTE: this will run the program itself: + ```sh make clobber all ``` ### Alternate code: -One may try: +This code, which prints something slightly different, is provided as well. -``` -./jar.1.sh -``` +#### To build: -Or for the original $xurce might not compile using modern compilers, try: +NOTE: this will run the program itself. ```sh make clobber alt ``` -or even: +#### To run: + +Alternatively, you can run it directly: + ```sh ./jar.1.alt.sh ``` + ## Judges' remarks: On many systems the compiler will not allow you to send the object file to diff --git a/1989/jar.1/jar.1.alt.sh b/1989/jar.1/jar.1.alt.sh index b9d053b54..f123c5d70 100755 --- a/1989/jar.1/jar.1.alt.sh +++ b/1989/jar.1/jar.1.alt.sh @@ -4,5 +4,12 @@ # run/compile it rm -f jar.1.alt.o cc jar.1.alt.c -c -cat jar.1.alt.o | strings +# we do it this way to prevent ShellCheck from whining about useless use of cat, +# a most ill-famed warning. Why is it ill-famed? Because there is no such thing +# as a useless cat! In fact, the fact cats exist is proof that the Earth is NOT +# flat: if it was flat they would have pushed everything off it by now! :-) And +# besides that, they provide hours and hours, years and years even, of joy and +# companionship to ailurophiles and, contrary to popular belief, they most +# certainly do have personalities and they can be very sociable too! +strings < jar.1.alt.o rm -f jar.1.alt.o diff --git a/1989/jar.1/jar.1.sh b/1989/jar.1/jar.1.sh index fecb4cc0b..9c1582c6b 100755 --- a/1989/jar.1/jar.1.sh +++ b/1989/jar.1/jar.1.sh @@ -4,5 +4,12 @@ # run/compile it rm -f jar.1.o cc jar.1.c -c -cat jar.1.o | strings +# we do it this way to prevent ShellCheck from whining about useless use of cat, +# a most ill-famed warning. Why is it ill-famed? Because there is no such thing +# as a useless cat! In fact, the fact cats exist is proof that the Earth is NOT +# flat: if it was flat they would have pushed everything off it by now! :-) And +# besides that, they provide hours and hours, years and years even, of joy and +# companionship to ailurophiles and, contrary to popular belief, they most +# certainly do have personalities and they can be very sociable too! +strings < jar.1.o rm -f jar.1.o diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 5823f6fa6..abaa951eb 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -502,11 +502,26 @@ entry as seeing the code with the result at once is far more beautiful. ## [1989/fubar](1989/fubar/fubar.c) ([README.md](1989/fubar/README.md])) -Cody got this to work with modern systems. The `main()` issues were an +Cody got this to work with modern systems. The main issues were that an `#include` had to be added along with fixing the path (due to `.` not being in `$PATH`) to files referred to in the code. +## [1989/jar.1](1989/jar.1/jar.1.c) ([README.md](1989/jar.1/README.md])) + +To prevent annoying output to `/dev/tty` we changed the code to simulate the +output via `strings(1)` but Cody removed the ill-famed `useless use of cat` to +shut ShellCheck up. Why is it ill-famed? Because there is no such thing as a +useless cat, that's why! For instance, the fact they even exist is proof that +the Earth is **NOT** flat: because if it was they would have pushed everything +off it by now! :-) They're also a great joy to all ailurophiles and yes they +most certainly do have a personality and they can be very sociable. + +Whilst he was at it, Cody made it so that one need not run the alt script or alt +code directly, to match that of the main entry. As we simulate the functionality +anyway, and since one may still run the code or the script (for the original +entry and the alt code) anyway, it works out well. + ## [1989/jar.2](1989/jar.2/jar.2.c) ([README.md](1989/jar.2/README.md])) Cody fixed this to work with modern compilers. Modern compilers do not allow