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.
This commit is contained in:
1 parent
8da99acce0
commit
9bcfcea20c
4 files changed
+64
-2
No files matched your search
@@ -6,4 +6,7 @@ indent.c
|
||||
indent.o
|
||||
prog.orig
|
||||
rcm
|
||||
rcm.cp2.c
|
||||
rcm.cp.c
|
||||
rcm.cp.c.gz
|
||||
rcm.orig
|
||||
+7
-2
@@ -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:
|
||||
|
||||
|
||||
Executable
+49
@@ -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
|
||||
|
||||
@@ -2166,6 +2166,11 @@ the function in the pointer assignment.
|
||||
NOTE: if there is no X server running this program will still crash.
|
||||
|
||||
|
||||
## <a name="1996_rcm"></a>[1996/rcm](/1996/rcm/rcm.c) ([README.md](/1996/rcm/README.md]))
|
||||
|
||||
[Cody](#cody) added the [try.sh](/1996/rcm/try.sh) script.
|
||||
|
||||
|
||||
## <a name="1996_schweikh1"></a>[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
|
||||
|
||||
Reference in new issue
Block a user