diff --git a/1985/august/README.md b/1985/august/README.md index 84e6dbac2..6cde65b9e 100644 --- a/1985/august/README.md +++ b/1985/august/README.md @@ -15,7 +15,7 @@ make all ### Try: ```sh -./august | head -n 10 +./try.sh ``` If you have the `primes(6)` tool (sometimes part of [BSD @@ -27,6 +27,10 @@ what of the output in the first `N` (say `15` or `25`) lines are primes: ./primes.sh 25 ``` +Note that `try.sh` will run this script anyway, telling you where to get +`primes(6)` if you don't have it installed, but it will only run with the +default value of 15, rather than trying several different values. + ## Judges' remarks: diff --git a/1985/august/primes.sh b/1985/august/primes.sh index a7743ea07..e64d220c4 100755 --- a/1985/august/primes.sh +++ b/1985/august/primes.sh @@ -18,8 +18,11 @@ if [[ -n "$PRIMES" ]]; then while read -r n; do primes "$n" $((n + 1)); done < <((./august | head -n "$COUNT" )) else echo "primes not installed" 1>&2 + echo 1>&2 echo "See the following GitHub repo:" 1>&2 - echo "" 1>&2 - echo " https://github.com/vattam/BSDGames" + echo 1>&2 + echo " https://github.com/vattam/BSDGames" 1>&2 + echo 1>&2 + echo "and after installing try again." exit 1 fi diff --git a/1985/august/try.sh b/1985/august/try.sh new file mode 100755 index 000000000..6ad209e2c --- /dev/null +++ b/1985/august/try.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1985/august +# + +# 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 + +REV="$(type -P rev)" +PRIMES=$(type -P primes) + +read -r -n 1 -p "Press any key to run: ./august | head -n 11: " +echo 1>&2 +./august | head -n 11 + +if [[ -n "$REV" ]]; then + echo 1>&2 + read -r -n 1 -p "Press any key to reverse bits: " + echo 1>&2 + ./august | head -n 11 | "$REV" +fi + +# run primes.sh too +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./primes.sh: " +echo 1>&2 +./primes.sh +exit 0 diff --git a/thanks-for-help.md b/thanks-for-help.md index dd106b159..dfcfa73eb 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -191,6 +191,10 @@ either the default or user specified. The inspiration was the previous 'try' command he gave to have fun with finding primes that might seem unusual in a way. +Cody also added the [try.sh](/1985/august/try.sh) script (which calls +`primes.sh` whether `primes(6)` is installed or not but it only does it once +with the default value). + ## [1985/lycklama](/1985/lycklama/lycklama.c) ([README.md](/1985/lycklama/README.md]))