From 26cb7525761fd1c1c264e5002e728f458a6e5a54 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 22 Mar 2009 21:04:22 +0100 Subject: help: -c for check only, -a to show all available infos --- etc/functions/help | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'etc') diff --git a/etc/functions/help b/etc/functions/help index 9a08988..62278a8 100755 --- a/etc/functions/help +++ b/etc/functions/help @@ -2,10 +2,19 @@ ## wrapper around man, finfo, etc typeset -a methods typeset method -typeset -i found=0 - +typeset -i found check_only all methods=(man function builtin apt) +while [[ $1 == -* ]] { + case $1 in + -c|--check-only) check_only=1 ;; + -a|--all) all=1 ;; + -|--) shift; break ;; + *) echo "unknown option: $1" ;; + esac + shift +} + function help_check_man { man -w $1 &> /dev/null } function help_check_function { whichf $1 &> /dev/null } function help_check_builtin { (( ${+builtins[$1]} )) } @@ -22,9 +31,13 @@ function help_show_apt { for method in $methods; { if help_check_$method $1; then - help_show_$method $1 ((found++)) - break + if ((check_only)) { + echo $method + continue + } + help_show_$method $1 + ((all)) || break fi } -- cgit v1.2.3