aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgames/rndn8
1 files changed, 7 insertions, 1 deletions
diff --git a/games/rndn b/games/rndn
index ecc374b1..ebbee9f6 100755
--- a/games/rndn
+++ b/games/rndn
@@ -34,7 +34,13 @@ done
shift "$((OPTIND-1))"
# If no seed given, get one from Bash's $RANDOM
-: "${seed:=$RANDOM}" ** 2
+: "${seed:=$((RANDOM ** 2))}"
+
+# Check seed meets algorithm conditions
+if [[ $seed == *[^0-9]* ]] || ((seed < 0)) ; then
+ printf >&2 '%s: error: seed must be non-negative integer\n' "$self"
+ exit 2
+fi
# Apply algorithm
for ((seed += 10, i = 0; i < ${#seed}; i++)) ; do