diff options
Diffstat (limited to 'bin/han.bash')
-rw-r--r-- | bin/han.bash | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/bin/han.bash b/bin/han.bash index 6ab0b3e7..5e5d67c2 100644 --- a/bin/han.bash +++ b/bin/han.bash @@ -1,5 +1,4 @@ # Abstract calls to Bash help vs man(1) -self=han # Ensure we're using at least version 3.0 # shellcheck disable=SC2128 @@ -13,22 +12,6 @@ if ((BASH_VERSINFO[0] >= 4)) ; then helpopts=(-m) fi -# Create a temporary directory with name in $td, and a trap to remove it when -# the script exits -td= -cleanup() { - [[ -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" >"$td"/"$1".help 2>/dev/null ; then - (cd -- "$td" && "$PAGER" -s -- "$1".help) - -# Otherwise, just pass all the arguments to man(1) -else - man "$@" -fi +# Call `help`, with the `-m` flag if available; if it errors out (discard +# stderr), run `man` instead +help "${helpopts[@]}" -- "$@" 2>/dev/null || man -- "$@" |