summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-22 21:04:22 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-22 21:04:22 +0100
commit26cb7525761fd1c1c264e5002e728f458a6e5a54 (patch)
tree86a5cc04c96fdda9b0bc7e52f7cd08e01d1782b3
parent4a92d24137fe74ef91297d26ba8c221be68e1f2d (diff)
help: -c for check only, -a to show all available infos
-rwxr-xr-xetc/functions/help21
1 files changed, 17 insertions, 4 deletions
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
}