Merge pull request #2169 from xexyl/herrmann12001-try

Fix 2001/herrmann1/try.sh
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-02-05 13:34:06 -08:00
commit c4020fc590
19 files changed
+270 -83

No files matched your search

+6 -6
View File
@@ -25,17 +25,17 @@ echo 1>&2
echo 'Hello, world!' | ./anderson
echo 1>&2
read -r -n 1 -p "Press any key to run: ./anderson < anderson.c: "
read -r -n 1 -p "Press any key to run: ./anderson < anderson.c (space = next page, q = quit): "
echo 1>&2
./anderson < anderson.c
./anderson < anderson.c | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: ./anderson < README.md: "
read -r -n 1 -p "Press any key to run: ./anderson < README.md (space = next page, q = quit): "
echo 1>&2
./anderson < README.md
./anderson < README.md | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: cat README.md anderson.c | ./anderson: "
read -r -n 1 -p "Press any key to run: cat README.md anderson.c | ./anderson (space = next page, q = quit): "
echo 1>&2
cat README.md anderson.c | ./anderson
cat README.md anderson.c | ./anderson | less -rEXFK
echo 1>&2
+1
View File
@@ -10,5 +10,6 @@ indent.o
lavabus.glic
lavabus.glic2
lenna.pgm
michael.glic
new.pgm
prog.orig
+1 -1
View File
@@ -209,7 +209,7 @@ clean:
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -rf *.dSYM
${RM} -rf *.dSYM michael.glic
@-if [ -e sandwich ]; then \
${RM} -f sandwich; \
echo 'ate sandwich'; \
+5 -14
View File
@@ -19,22 +19,13 @@ clear
# be determined: we just use a default value.
#
# try getting the columns the simple way first: tput cols
COLUMNS="$(tputs cols)"
# In this case we might be able to get away with resolving this ShellCheck
# warning:
#
# SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
#
# but we want to assign the value to COLUMNS and at the same time make sure tput
# worked. Thus we disable this warning.
#
# shellcheck disable=SC2181
if [[ "$?" -ne 0 ]]; then
# if tput failed for any reason try stty(1) with awk(1):
if ! COLUMNS="$(tput cols)"; then
# if tput failed for any reason try stty(1) with awk(1).
#
# Disable this warning of shellcheck as it's wrong: awk needs single quotes.
#
# SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
#
# SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
# https://www.shellcheck.net/wiki/SC2016
# shellcheck disable=SC2016
COLUMNS="$(stty size|awk '{print $NF}')"
+8
View File
@@ -17,6 +17,14 @@ make
For some fun every time you log in try running this from your `.bashrc` or
equivalent file!
You might also like to try:
```sh
./try.sh
INSULTS=15 ./try.sh
```
## Judges' remarks:
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2000/briddlebane
#
# 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
[[ -z "$INSULTS" ]] && INSULTS=10
echo "$INSULTS" | grep -qE '^[0-9]+'
if [[ "${PIPESTATUS[1]}" -ne 0 ]]; then
echo "INSULTS value not a positive number, fix and run again."
exit 1
fi
for ((i=0; i<"$INSULTS"; i++)); do
./briddlebane
sleep 1
done
+3 -3
View File
@@ -23,7 +23,7 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./saitou | tee aku.c (space = next page, q = quit): "
echo 1>&2
./saitou | tee aku.c | less -rEXF
./saitou | tee aku.c | less -rEXFK
read -r -n 1 -p "Press any key to run: make soku >/dev/null || exit 1: "
echo 1>&2
@@ -32,7 +32,7 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./soku | tee soku.c (space = next page, q = quit): "
echo 1>&2
./soku | tee soku.c | less -rEXF
./soku | tee soku.c | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: make zan >/dev/null || exit 1: "
@@ -42,7 +42,7 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./zan | tee zan.c (space = next page, q = quit): "
echo 1>&2
./zan | tee zan.c | less -rEXF
./zan | tee zan.c | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: make aku >/dev/null || exit 1: "
+45
View File
@@ -29,6 +29,11 @@ moon()
./"$NATORI"
echo 1>&2
fi
if [[ "$i" != 10 ]]; then
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
fi
done
echo 1>&2
@@ -37,19 +42,39 @@ moon()
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
else
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
fi
@@ -61,19 +86,39 @@ moon()
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
else
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
fi
+44
View File
@@ -29,6 +29,10 @@ moon()
./"$NATORI".alt
echo 1>&2
fi
if [[ "$i" != 10 ]]; then
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
fi
done
echo 1>&2
@@ -37,19 +41,39 @@ moon()
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
else
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
fi
@@ -61,19 +85,39 @@ moon()
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
else
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI".alt
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./"$NATORI"
fi
+2 -2
View File
@@ -34,11 +34,11 @@ echo 1>&2
read -r -n 1 -p "Press any key to show try.sh.txt (space = next page, q = quit): "
echo 1>&2
less -rEXF try.sh.txt
less -rEXFK try.sh.txt
echo 1>&2
echo "$ diff try.sh try.sh.txt"
read -r -n 1 -p "Press any key to see diff (space = next page, q = quit): " 1>&2
diff try.sh try.sh.txt | less -rEXF
diff try.sh try.sh.txt | less -rEXFK
rm -f try.sh.txt
+31 -23
View File
@@ -23,12 +23,11 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0.001 $(./dmy2jd 7.8 1 1610): "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
# We actually need word splitting here so we disable the shellcheck warning
# SC2046.
#
# SC2046 (warning): Quote this to prevent word splitting.
# https://www.shellcheck.net/wiki/SC2046
# shellcheck disable=SC2046
./rince 0.001 $(./dmy2jd 7.8 1 1610)
echo 1>&2
@@ -48,38 +47,47 @@ echo 1>&2
./rince 0.01 2441193.6
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 7.8 1 1610): "
read -r -n 1 -p "Press any key to run: ./dmy2jd 7.8 1 1610: "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
./dmy2jd 7.8 1 1610
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 \$(./dmy2jd 7.8 1 1610): "
echo 1>&2
# We actually need word splitting here so we disable the shellcheck warning
# SC2046.
#
# SC2046 (warning): Quote this to prevent word splitting.
# https://www.shellcheck.net/wiki/SC2046
# shellcheck disable=SC2046
./rince 0 $(./dmy2jd 7.8 1 1610)
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 8.8 1 1610): "
read -r -n 1 -p "Press any key to run: ./dmy2jd 8.8 1 1610: "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
./dmy2jd 8.8 1 1610
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 \$(./dmy2jd 8.8 1 1610): "
echo 1>&2
# We actually need word splitting here so we disable the shellcheck warning
# SC2046.
#
# SC2046 (warning): Quote this to prevent word splitting.
# https://www.shellcheck.net/wiki/SC2046
# shellcheck disable=SC2046
./rince 0 $(./dmy2jd 8.8 1 1610)
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 10.8 1 1610): "
read -r -n 1 -p "Press any key to run: ./dmy2jd 10.8 1 1610: "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
./dmy2jd 10.8 1 1610
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 \$(./dmy2jd 10.8 1 1610): "
echo 1>&2
# We actually need word splitting here so we disable the shellcheck warning
# SC2046.
#
# SC2046 (warning): Quote this to prevent word splitting.
# https://www.shellcheck.net/wiki/SC2046
# shellcheck disable=SC2046
./rince 0 $(./dmy2jd 10.8 1 1610)
echo 1>&2
+9
View File
@@ -28,6 +28,15 @@ paint dry :-) ) you might also try:
./try.sh
```
Alternatively, you can check on it later on, to see all the entry does. Or if
you wish to make it run faster, you can override how long it sleeps per
iterations and how many iterations it runs. For instance to make it sleep only
30 seconds and run only twice:
```sh
SLEEP=30 ITERATIONS=2 ./try.sh
```
## Judges' remarks:
+36 -9
View File
@@ -6,23 +6,50 @@
# 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
[[ -z "$CC" ]] && CC="cc"
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "This will take a long time to run to completion: " 1>&2
# get the number of seconds to sleep in between runs (def: 60)
[[ -z "$SLEEP" ]] && SLEEP=60
# verify it's a positive number:
echo "$SLEEP" | grep -qE '^[0-9]+'
if [[ "${PIPESTATUS[1]}" -ne 0 ]]; then
echo "SLEEP value not a positive number, fix and run again."
exit 1
fi
# get the number of iterations to run (default: 60)
[[ -z "$ITERATIONS" ]] && ITERATIONS=60
# verify it's a positive number:
echo "$ITERATIONS" | grep -qE '^[0-9]+'
if [[ "${PIPESTATUS[1]}" -ne 0 ]]; then
echo "ITERATIONS value not a positive number, fix and run again."
exit 1
fi
echo "If you did not override \$SLEEP and \$ITERATIONS this will take a long" 1>&2
echo "time to run to completion: approximately one hour. If you do not care to" 1>&2
echo "wait such a long time, which we presume is probably quite likely, you" 1>&2
echo "you might wish to run this entry like the following: " 1>&2
echo 1>&2
echo " ./schneiderwent" 1>&2
echo " ./schneiderwent schneiderwent.data" 1>&2
echo 1>&2
echo "at various times throughout the day, preferably at different" 1>&2
echo "minutes of the hours." 1>&2
echo 1>&2
echo "Alternatively, you can leave this running in a console tab for an hour" 1>&2
echo "and look back at it later, so that you can see all the entry does." 1>&2
echo 1>&2
read -r -n 1 -p "Press any key to start: "
echo 1>&2
i=0
while [[ "$i" -lt 60 ]]; do
while [[ "$i" -lt "$ITERATIONS" ]]; do
./schneiderwent
./schneiderwent schneiderwent.data
sleep 60
sleep "$SLEEP"
((i++))
done
+2
View File
@@ -5,7 +5,9 @@ indent
indent.c
indent.o
mkentry
mkentry.help.txt
prog.orig
tomx
tomx.alt
tomx.help.txt
tomx.orig
+26 -11
View File
@@ -15,34 +15,49 @@ make CC="$CC" alt >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "Using tomx.alt.c to compile mkentry.c directly:" 1>&2
read -r -n 1 -p "Press any key to run: rm -v -f mkentry: "
echo 1>&2
rm -v -f mkentry
echo 1>&2
read -r -n 1 -p "Press any key to run: chmod +x tomx.alt.c: "
echo 1>&2
chmod +x tomx.alt.c
echo 1>&2
read -r -n 1 -p "Press any key to run: rm -vf mkentry: "
echo 1>&2
rm -vf mkentry
echo 1>&2
echo "Using tomx.alt.c as an executable to compile mkentry.c directly:" 1>&2
read -r -n 1 -p "Press any key to run: ./tomx.alt.c: "
echo 1>&2
./tomx.alt.c
echo 1>&2
echo "Using tomx.alt.c as a Makefile to compile mkentry.c:" 1>&2
read -r -n 1 -p "Press any key to run: rm -vf mkentry: "
read -r -n 1 -p "Press any key to run: ./mkentry -h | tee mkentry.help.txt: "
echo 1>&2
rm -vf mkentry
./mkentry | tee mkentry.help.txt
echo 1>&2
read -r -n 1 -p "Press any key to run: rm -v -f mkentry: "
echo 1>&2
rm -v -f mkentry
echo 1>&2
echo "Using tomx.alt.c as a Makefile to compile mkentry.c:" 1>&2
read -r -n 1 -p "Press any key to run: make -f tomx.alt.c: "
echo 1>&2
make -f tomx.alt.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./tomx.alt: "
echo 1>&2
./tomx.alt
read -r -n 1 -p "Press any key to run: ./tomx.alt (mkentry compiled from tomx.alt.c): "
echo 1>&2
./tomx.alt | tee tomx.help.txt
echo 1>&2
read -r -n 1 -p "Press any key to run: diff -s mkentry.help.txt tomx.help.txt: "
echo 1>&2
diff -s mkentry.help.txt tomx.help.txt
echo 1>&2
read -r -n 1 -p "Press any key to remove mkentry.help.txt and tomx.help.txt: "
echo 1>&2
rm -v -f mkentry.help.txt tomx.help.txt
+9 -9
View File
@@ -15,15 +15,14 @@ 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: ./tomx: "
read -r -n 1 -p "Press any key to run: ./tomx (compiled from tomx.c): "
echo 1>&2
./tomx
echo 1>&2
echo "Using source code to compile tomx.c: " 1>&2
read -r -n 1 -p "Press any key to run: rm -vf tomx: "
read -r -n 1 -p "Press any key to run: rm -v -f tomx: "
echo 1>&2
rm -vf tomx
rm -v -f tomx
echo 1>&2
read -r -n 1 -p "Press any key to run: chmod +x tomx.c: "
@@ -31,27 +30,28 @@ echo 1>&2
chmod +x tomx.c
echo 1>&2
echo "Using source code to compile tomx.c: " 1>&2
read -r -n 1 -p "Press any key to run: ./tomx.c: "
echo 1>&2
./tomx.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./tomx (a second time): "
read -r -n 1 -p "Press any key to run: ./tomx (compiled by tomx.c as an executable itself): "
echo 1>&2
./tomx
echo 1>&2
echo "Using tomx.c as a Makefile:" 1>&2
read -r -n 1 -p "Press any key to run: rm -vf tomx: "
read -r -n 1 -p "Press any key to run: rm -v -f tomx: "
echo 1>&2
rm -vf tomx
rm -v -f tomx
echo 1>&2
echo "Using tomx.c as a Makefile:" 1>&2
read -r -n 1 -p "Press any key to run: make -f tomx.c: "
echo 1>&2
make -f tomx.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./tomx (a third time): "
read -r -n 1 -p "Press any key to run: ./tomx (built from tomx.c as a Makefile): "
echo 1>&2
./tomx
echo 1>&2
+2 -2
View File
@@ -20,12 +20,12 @@ clear
echo "$ ./herrmann1.sh 'prg=herrmann1.times2'" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./herrmann1.sh 'prg=herrmann1.times2'
./herrmann1.sh 'prg=herrmann1.times2' | less -rEXFK
echo 1>&2
echo "$ ./herrmann1.sh 'prg=herrmann1.gcd'" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./herrmann1.sh 'prg=herrmann1.gcd'
./herrmann1.sh 'prg=herrmann1.gcd' | less -rEXFK
echo 1>&2
+9 -3
View File
@@ -28,7 +28,7 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: grep '[0-9]' prog.c || echo \"no digits in prog.c!\": "
echo 1>&2
grep -q '[0-9]' prog.c || echo "no digits in prog.c!"
grep -q '[0-9]' prog.c || echo "no digits found in prog.c!"
echo 1>&2
read -r -n 1 -p "Press any key to show calc.in (space = next page, q = quit): "
@@ -46,9 +46,15 @@ echo 1>&2
less -rEXFK try.this.txt
echo 1>&2
read -r -n 1 -p "Press any key to run: ./calc < try.this.txt: "
read -r -n 1 -p "Press any key to run: ./calc < try.this.txt (space = net page, q = quit): "
echo 1>&2
./calc < try.this.txt | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: ./ecalc < try.this.txt (space = next page, q = quit): "
echo 1>&2
./ecalc < try.this.txt | less -rEXFK
echo 1>&2
./calc < try.this.txt
read -r -n 1 -p "Press any key to run: ./calc 42 # show hex value of 42: "
echo 1>&2
+3
View File
@@ -2511,6 +2511,9 @@ terminal.
[Cody](#cody) fixed this to compile in systems that require one to explicitly link in
`libm`.
Cody also added the [try.sh](/2000/briddlebane/try.sh) script for those who are
feeling a bit too confident, cocky or even happy :-)
## <a name="2000_dhyang"></a>[2000/dhyang](/2000/dhyang/dhyang.c) ([README.md](/2000/dhyang/README.md]))