1 |
17f6c75c
|
Serghei Mihai
|
#!/bin/sh
|
2 |
|
|
|
3 |
|
|
ME=`basename $0`
|
4 |
|
|
COMMANDDIR=`dirname $0`/lib
|
5 |
|
|
test -d ${COMMANDDIR} || COMMANDDIR=/usr/lib/`basename $0`
|
6 |
|
|
|
7 |
|
|
help() {
|
8 |
|
|
msg="$1"
|
9 |
|
|
test -n "$msg" && echo $msg
|
10 |
|
|
echo "syntaxe: $ME commande ..."
|
11 |
|
|
echo ""
|
12 |
|
|
echo "commandes disponibles:"
|
13 |
|
|
echo " help cette aide"
|
14 |
|
|
for fcom in $COMMANDDIR/*.help
|
15 |
|
|
do
|
16 |
|
|
com=`basename $fcom .help`
|
17 |
|
|
descr=`head -1 $fcom`
|
18 |
|
|
echo " "$com" "$descr
|
19 |
|
|
done
|
20 |
|
|
test -n "$msg" && exit 1
|
21 |
|
|
exit 0
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
helpcmd() {
|
25 |
|
|
command=$1
|
26 |
|
|
xcommand=$COMMANDDIR/$command
|
27 |
|
|
test -x $xcommand || help "ERR: commande inconnue ($command)"
|
28 |
|
|
echo "$ME $command"
|
29 |
|
|
cat $xcommand.help
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
command=$1
|
33 |
|
|
test -z $command && help "ERR: commande manquante"
|
34 |
|
|
shift
|
35 |
|
|
|
36 |
|
|
case $command in
|
37 |
|
|
help)
|
38 |
|
|
test -z "$1" && help
|
39 |
|
|
helpcmd $1
|
40 |
|
|
;;
|
41 |
|
|
*)
|
42 |
|
|
xcommand=$COMMANDDIR/$command
|
43 |
|
|
test -x $xcommand || help "ERR: commande inconnue ($command)"
|
44 |
|
|
$xcommand "$@"
|
45 |
|
|
;;
|
46 |
|
|
esac
|