From 9bcfcea20c338ec9d3b8f3924115d1b00496fdf6 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Fri, 19 Jan 2024 05:12:26 -0800
Subject: [PATCH] Add 1996/rcm/try.sh
The 'to use' section was fixed also: it's not just specific gzipped
files but any so it now says 'file.gz' and adds that file.gz is any
gzipped file.
The try.sh script now has the command that used to be in to use and also
what was in the try section. It also copies rcm.c to rcm.cp.c and gzips
that file and then runs the program on that to show the source. All
paged through less(1), of course. Finally it does what the judges have
in their comments (which have been updated to say that the command is in
the try.sh script). The judges' command is naturally a shorter way to do
the one added in the try.sh script but it uses tee(1) to write both to
another file (piped to less(1)) so that it can compare the two.
Obviously the files will be the same but it shows how it works in
multiple ways.
---
1996/rcm/.gitignore | 3 +++
1996/rcm/README.md | 9 +++++++--
1996/rcm/try.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++
thanks-for-help.md | 5 +++++
4 files changed, 64 insertions(+), 2 deletions(-)
create mode 100755 1996/rcm/try.sh
diff --git a/1996/rcm/.gitignore b/1996/rcm/.gitignore
index 2d74aa8cf..a7113ed57 100644
--- a/1996/rcm/.gitignore
+++ b/1996/rcm/.gitignore
@@ -6,4 +6,7 @@ indent.c
indent.o
prog.orig
rcm
+rcm.cp2.c
+rcm.cp.c
+rcm.cp.c.gz
rcm.orig
diff --git a/1996/rcm/README.md b/1996/rcm/README.md
index f2032e480..a23a63a6d 100644
--- a/1996/rcm/README.md
+++ b/1996/rcm/README.md
@@ -8,16 +8,18 @@ make all
## To use:
```sh
-./rcm < rfc1951.gz
+./rcm < file.gz
```
+where `file.gz` is some gzipped file.
+
## Try:
For more information try:
```sh
-./rcm < rfc1952.gz
+./try.sh
```
@@ -29,6 +31,9 @@ For a good no-op try:
gzip -c < rcm.c | ./rcm
```
+NOTE: this is done in the [try.sh](try.sh) script as well, along with some other
+commands including a way to do the above command but with more steps.
+
## Author's remarks:
diff --git a/1996/rcm/try.sh b/1996/rcm/try.sh
new file mode 100755
index 000000000..8ca9bb960
--- /dev/null
+++ b/1996/rcm/try.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#
+# try.sh - show IOCCC winner 1996/rcm
+#
+
+# 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
+
+
+read -r -n 1 -p "Press any key to run: ./rcm < rfc1951.gz (space = next page, q = quit): "
+echo 1>&2
+./rcm < rfc1951.gz | less -rEXF
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./rcm < rfc1952.gz (space = next page, q = quit): "
+echo 1>&2
+./rcm < rfc1952.gz | less -rEXF
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: cp -vf rcm.c rcm.cp.c; gzip rcm.cp.c: "
+echo 1>&2
+cp -vf rcm.c rcm.cp.c; gzip rcm.cp.c
+
+read -r -n 1 -p "Press any key to run: ./rcm < rcm.cp.c.gz | tee rcm.cp.c (space = next page, q = quit): "
+echo 1>&2
+./rcm < rcm.cp.c.gz | tee rcm.cp.c | less -rEXF
+echo 1>&2
+rm rcm.cp.c.gz
+
+read -r -n 1 -p "Press any key to run: gzip -c < rcm.c | ./rcm | tee rcm.cp2.c (space = next page, q = quit): "
+echo 1>&2
+gzip -c < rcm.c | ./rcm | tee rcm.cp2.c | less -rEXF
+echo 1>&2
+
+read -r -n 1 -p "Press any key to show diff between rcm.cp.c and rcm.cp2.c: "
+echo 1>&2
+diff -s rcm.cp.c rcm.cp2.c
+echo 1>&2
+rm -f rcm.cp.c rcm.cp2.c
+
diff --git a/thanks-for-help.md b/thanks-for-help.md
index c0877cf0b..fd125bb5a 100644
--- a/thanks-for-help.md
+++ b/thanks-for-help.md
@@ -2166,6 +2166,11 @@ the function in the pointer assignment.
NOTE: if there is no X server running this program will still crash.
+## [1996/rcm](/1996/rcm/rcm.c) ([README.md](/1996/rcm/README.md]))
+
+[Cody](#cody) added the [try.sh](/1996/rcm/try.sh) script.
+
+
## [1996/schweikh1](/1996/schweikh1/schweikh1.c) ([README.md](/1996/schweikh1/README.md]))
The author stated that `-I/usr/include` is needed by gcc in Solaris because