blob: 6886e4a53b3bfd545371e4df9103688522250fcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
if [[ -z "$jh_cmd" ]]; then
export jh_cmd=$0
fi
export jh_short=${jh_cmd##*/}
if [[ -z "$JH_PATH" ]]; then
export JH_PATH=/usr/share/jh
fi
usage() {
cmd="${1-$0}"
cmd="${cmd##*/jh-}"
file="$JH_PATH/jh-$cmd.help.txt"
if [[ -z "$cmd" ]]; then
echo "Usage: $jh_short <command> [command-specific-arguments]"
echo "Java helper for PKGBUILDs"
echo ""
"$jh_short" list-commands|sed 's/./ &/'
elif [[ -f "$JH_PATH/jh-$cmd.help.txt" ]]; then
sed "s|@cmd@|$jh_short|g" "$file" >> /dev/stderr
else
echo "$jh_short: Cannot find help file for '$cmd'" >> /dev/stderr
fi
}
run() {
if [[ $# < 1 ]]; then
usage ''
exit 1;
fi
cmd=$1
shift
file="$JH_PATH/jh-$cmd"
if [[ -x "$file" ]]; then
"$file" "$@"
exit $?
else
echo "$jh_short: Cannot find command '$cmd'" >> /dev/stderr
fi
}
[[ "$jh_cmd" == "$0" ]] && run "$@"
|