aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-16 21:10:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-16 21:10:09 +1200
commit78848f19450b2ba7b747c346eb1cc07e20f4e324 (patch)
tree3a8b4320755331c7522ad524cb2680aa6cef457c /bin
parentQuote variable in param expansion in eds(1) (diff)
downloaddotfiles-78848f19450b2ba7b747c346eb1cc07e20f4e324.tar.gz
dotfiles-78848f19450b2ba7b747c346eb1cc07e20f4e324.zip
Swap td(1) for mktemp(1) in han(1)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/han12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/han b/bin/han
index 5aa4a8b5..efe4ceea 100755
--- a/bin/han
+++ b/bin/han
@@ -12,18 +12,20 @@ if ((BASH_VERSINFO[0] >= 4)) ; then
helpopts=(-m)
fi
-# Create a temporary file and set up a trap to get rid of it.
-tmpdir=$(mktemp -dt "$self".XXXXXX) || exit
+# Create a temporary directory with name in $td, and a trap to remove it when
+# the script exits
+td=
cleanup() {
- rm -fr -- "$tmpdir"
+ [[ -n "$td" ]] && rm -fr -- "$td"
}
trap cleanup EXIT
+td=$(mktd "$self") || exit
# If we have exactly one argument and a call to the help builtin with that
# argument succeeds, display its output with `pager -s`.
if (($# == 1)) &&
- help "${helpopts[@]}" "$1" >"$tmpdir"/"$1".help 2>/dev/null ; then
- (cd -- "$tmpdir" && pager -s -- "$1".help)
+ help "${helpopts[@]}" "$1" >"$td"/"$1".help 2>/dev/null ; then
+ (cd -- "$td" && "$PAGER" -s -- "$1".help)
# Otherwise, just pass all the arguments to man(1).
else