]> git.armaanb.net Git - bin.git/commitdiff
fortune: make seed POSIX compliant
authorArmaan Bhojwani <me@armaanb.net>
Tue, 6 Apr 2021 14:04:07 +0000 (10:04 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Tue, 6 Apr 2021 14:04:07 +0000 (10:04 -0400)
fortune

diff --git a/fortune b/fortune
index cbf19848130a0f74ad677e2fc98f0ae98cf901b1..fde90857a6d61e6d17080364c1c9a470158f888a 100755 (executable)
--- a/fortune
+++ b/fortune
@@ -89,7 +89,7 @@ $1 == "%" {
 }
 
 END {
-  "date +%N" | getline time
-  srand(time)
+  "od -A n -t d -N 3 /dev/urandom" | getline seed
+  srand(seed)
   print fortunes[int(rand() * (f - 2)) + 1]
 }' $FILE