#!/bin/sh ME=`basename $0` COMMANDDIR=`dirname $0`/lib test -d ${COMMANDDIR} || COMMANDDIR=/usr/lib/`basename $0` help() { msg="$1" test -n "$msg" && echo $msg echo "syntaxe: $ME commande ..." echo "" echo "commandes disponibles:" echo " help cette aide" for fcom in $COMMANDDIR/*.help do com=`basename $fcom .help` descr=`head -1 $fcom` echo " "$com" "$descr done test -n "$msg" && exit 1 exit 0 } helpcmd() { command=$1 xcommand=$COMMANDDIR/$command test -x $xcommand || help "ERR: commande inconnue ($command)" echo "$ME $command" cat $xcommand.help } command=$1 test -z $command && help "ERR: commande manquante" shift case $command in help) test -z "$1" && help helpcmd $1 ;; *) xcommand=$COMMANDDIR/$command test -x $xcommand || help "ERR: commande inconnue ($command)" $xcommand "$@" ;; esac