aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-04 12:03:49 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-04 12:03:49 +1200
commit2c52d419be368c4d9e8e97ca67299ece9e23331b (patch)
tree85a8d963f72f16f5636a7aa1b4a406050f3c60c5
parentChange igex(1) into POSIX sh, simplify (diff)
downloaddotfiles-2c52d419be368c4d9e8e97ca67299ece9e23331b.tar.gz
dotfiles-2c52d419be368c4d9e8e97ca67299ece9e23331b.zip
Make mktd(1) call in rndl(1) only if needed
-rwxr-xr-xbin/rndl14
1 files changed, 7 insertions, 7 deletions
diff --git a/bin/rndl b/bin/rndl
index 978fc194..3e92044c 100755
--- a/bin/rndl
+++ b/bin/rndl
@@ -1,13 +1,13 @@
#!/bin/sh
# Print a random line from input
-td=
-cleanup() {
- rm -fr -- "$td"
-}
-for sig in EXIT HUP INT TERM ; do
- trap cleanup "$sig"
-done
if [ "$#" -eq 0 ] ; then
+ td=
+ cleanup() {
+ rm -fr -- "$td"
+ }
+ for sig in EXIT HUP INT TERM ; do
+ trap cleanup "$sig"
+ done
td=$(mktd rndl) || exit
set -- "$td"/stdin
cat >"$td"/stdin