Add 1998/df/try.sh

This script runs repeatedly until (when prompted) one hits 'q' (or 'Q')
or else sends ctrl-c/intr. I also added a question to the extra credit
questions: are there any misspelt words and if there are what are they?
I also added that there's a way to cheat very easily but I did not say
how to do it. It should be pretty obvious how to do it to anyone who
tries the program once or if not once a few times.
This commit is contained in:
Cody Boone Ferguson committed 2024-01-19 06:57:28 -08:00
1 parent ed47e4ab55
commit 99e79b1e13
3 files changed
+46 -3

No files matched your search

+14
View File
@@ -11,6 +11,19 @@ make all
./df ./df
``` ```
## Try:
```sh
./try.sh
```
This will run the program in a loop until you exit (`q` when prompted or
ctrl-c/intr).
Can you figure out a very simple pipeline to cheat?
## Judges' remarks; ## Judges' remarks;
Everyone talks about how data hiding can produce clearer code; I am Everyone talks about how data hiding can produce clearer code; I am
@@ -33,6 +46,7 @@ Extra credit questions:
- Where are the words stored? - Where are the words stored?
- How many words does this entry use? - How many words does this entry use?
- Can you add more words to the program and still make it work? - Can you add more words to the program and still make it work?
- Are there any misspelt words? If yes what are they?
## Author's remarks: ## Author's remarks:
Executable
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1998/df
#
# 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
while [[ 1 ]]; do
read -r -n 1 -p "Press any key to run ./df or 'q' to quit: "
echo 1>&2
if [[ "$REPLY" = "q" || "$REPLY" = "Q" ]]; then
exit 0
fi
./df
done
+7 -3
View File
@@ -2269,10 +2269,14 @@ prior to each run.
[Cody](#cody) changed a `int *` used for `fopen(3)` to be a `FILE *` to be more correct [Cody](#cody) changed a `int *` used for `fopen(3)` to be a `FILE *` to be more correct
and prevent any possible problems in some systems (which has happened). and prevent any possible problems in some systems (which has happened).
Cody also made the fixed version look more like the original version by using Cody also made the fixed version to look more like the original version by using
the old style of `main()` args so that it reads `i,love_unix` more naturally, the old style of `main()` args so that it reads `i,love_unix` more naturally,
and by changing the typedef `lint` (to `int` - see the code for why this has to and by changing the `typedef int lint` to be `typedef int _int`. See the code
be done in modern systems) to be `_int`. for why this has to be done this way.
Cody also added the [try.sh](/1998/df/try.sh) script which runs the program in a
loop until one hits `q` (or `Q`) or sends intr/ctrl-c. He also proposed there's
a way to cheat very easily. Can you figure out how?
## <a name="1998_dlowe"></a>[1998/dlowe](/1998/dlowe/dlowe.c) ([README.md](/1998/dlowe/README.md])) ## <a name="1998_dlowe"></a>[1998/dlowe](/1998/dlowe/dlowe.c) ([README.md](/1998/dlowe/README.md]))