aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-01 10:23:34 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-01 10:23:34 +1200
commita88bc7eefae9c0d187b2d41f3ff5e593b05239ad (patch)
tree8546b96e6fb570116e0cecd5362f553f8389b408
parentChange sue(8) to POSIX sh (diff)
downloaddotfiles-a88bc7eefae9c0d187b2d41f3ff5e593b05239ad.tar.gz
dotfiles-a88bc7eefae9c0d187b2d41f3ff5e593b05239ad.zip
Add rndi(1)
-rwxr-xr-xbin/rndi9
-rw-r--r--man/man1/rndi.117
2 files changed, 26 insertions, 0 deletions
diff --git a/bin/rndi b/bin/rndi
new file mode 100755
index 00000000..3b0ea005
--- /dev/null
+++ b/bin/rndi
@@ -0,0 +1,9 @@
+#!/usr/bin/awk -f
+# Get a low-quality random number between two integers. Note that depending on
+# implementation, this might return the same number if run in the same second.
+# It's only for trivial purposes.
+BEGIN {
+ srand()
+ print int(ARGV[1]+rand()*(ARGV[2]-ARGV[1]+1))
+ exit
+}
diff --git a/man/man1/rndi.1 b/man/man1/rndi.1
new file mode 100644
index 00000000..d2ce5ffd
--- /dev/null
+++ b/man/man1/rndi.1
@@ -0,0 +1,17 @@
+.TH RNDI 1 "August 2016" "Manual page for rndi"
+.SH NAME
+.B rndi
+\- return a low-quality random integer between two bounds
+.SH SYNOPSIS
+.B rndi
+.br
+.B 0 10
+.SH DESCRIPTION
+.B rndi
+returns a random integer ranging from the first argument to the second argument
+in a POSIX-compliant way (using awk). The answer returned is low-quality and if
+run in the same second as a previous run may even return the same result in
+some implementations. This should not be used in any sort of security or
+statistical context; the author wrote it to choose random background images.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>