aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-04 16:23:21 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-04 16:23:21 +1200
commite816a052f7a79dd988e158ab147099435da64059 (patch)
treefee0fef6bead68134a26d304b52908984f34773d /bin
parentNo real need to use use test over [...] (diff)
downloaddotfiles-e816a052f7a79dd988e158ab147099435da64059.tar.gz
dotfiles-e816a052f7a79dd988e158ab147099435da64059.zip
Workaround to give han(1) help pages better names
Diffstat (limited to 'bin')
-rwxr-xr-xbin/han10
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/han b/bin/han
index d8d1e8dd..0d2f6755 100755
--- a/bin/han
+++ b/bin/han
@@ -21,6 +21,7 @@
# Author: Tom Ryder <tom@sanctum.geek.nz>
# Copyright: 2015 Inspire Net Ltd
#
+self=han
# Give up completely if no BASH_VERSINFO (<2.0)
if ! test "$BASH_VERSINFO" ; then
@@ -35,16 +36,17 @@ if ((BASH_VERSINFO[0] >= 4)) ; then
fi
# Create a temporary file and set up a trap to get rid of it.
-out=$(mktemp)
+tmpdir=$(mktemp -dt "$self".XXXXX) || exit
cleanup() {
- rm -f -- "$out"
+ rm -fr -- "$tmpdir"
}
trap cleanup 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" >"$out" 2>/dev/null ; then
- pager -s -- "$out"
+if (($# == 1)) && \
+ help "${helpopts[@]}" "$1" >"$tmpdir"/"$1".help 2>/dev/null ; then
+ (cd -- "$tmpdir" && pager -s -- "$1".help)
# Otherwise, just pass all the arguments to man(1).
else