Add script primes.sh to 1985/august for fun

The inspiration of the script is based on a 'try' command I added to the
README.md a while back to have more fun with the entry. The difference
is that it allows you to specify the number of lines to print (or up to
the number of lines).

There might be some misleading output in a way but this is a mystery for
users to solve.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-16 10:09:46 -07:00
1 parent 90c80b3e69
commit c31796a55c
3 files changed
+43 -5

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
make everything || exit 1
PRIMES=$(type -P primes)
COUNT=15
if [[ "$#" -ge 1 ]]; then
COUNT="$1"
if ! [[ $COUNT =~ ^[0-9]+$ ]] ; then
echo "not a number: $COUNT" 1>&2
exit 1
fi
fi
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 "See the following GitHub repo:" 1>&2
echo "" 1>&2
echo " https://github.com/vattam/BSDGames"
exit 1
fi