aboutsummaryrefslogtreecommitdiff
path: root/bin/mktd
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-09 17:15:40 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-09 17:20:10 +1200
commit9fb350dc7c8cc5259ef24e0cb097031179fab1d6 (patch)
tree839dd0b8ee3f5323b1cd6aefa22b605b99437d62 /bin/mktd
parentMention nosls/sls flags in slsf(1) man page (diff)
downloaddotfiles-9fb350dc7c8cc5259ef24e0cb097031179fab1d6.tar.gz
dotfiles-9fb350dc7c8cc5259ef24e0cb097031179fab1d6.zip
Improve commenting/exit handling in binscripts
Diffstat (limited to 'bin/mktd')
-rwxr-xr-xbin/mktd10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/mktd b/bin/mktd
index 2a8f0e56..afbcf4bb 100755
--- a/bin/mktd
+++ b/bin/mktd
@@ -1,6 +1,12 @@
#!/bin/sh
# Try to make a random temp directory
+
+# Get a random seed from rnds(1); if it's empty, that's still workable
seed=$(rnds)
+
+# Build the intended directory name, with the last element a random integer
+# from 1..2^31
dn=${TMPDIR:-/tmp}/${1:-mktd}.$$.$(rndi 1 2147483648 "$seed")
-mkdir -m 700 -- "$dn" || exit 1
-printf '%s\n' "$dn"
+
+# Create the directory and print its name if successful
+mkdir -m 700 -- "$dn" && printf '%s\n' "$dn"