diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-06-04 16:23:21 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-06-04 16:23:21 +1200 |
commit | e816a052f7a79dd988e158ab147099435da64059 (patch) | |
tree | fee0fef6bead68134a26d304b52908984f34773d /bin | |
parent | No real need to use use test over [...] (diff) | |
download | dotfiles-e816a052f7a79dd988e158ab147099435da64059.tar.gz dotfiles-e816a052f7a79dd988e158ab147099435da64059.zip |
Workaround to give han(1) help pages better names
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/han | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 |