-
Notifications
You must be signed in to change notification settings - Fork 0
/
template
executable file
·55 lines (42 loc) · 900 Bytes
/
template
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
46
47
48
49
50
51
52
53
54
55
#!/bin/ksh
export LC_ALL=C
#scriptdir=$(cd "$(dirname "$0")"; pwd -P)
scriptdir="/usr/share/docprocess"
trap "[ -n \"\$rmcmd\" ] && eval \"rm \$rmcmd\"" ERR EXIT
if [ $# -lt 2 ]
then
echo "Usage: template.sh [template] [output extension] [parameters]" \
1>&2
exit 1
fi
if [ -z "$utilspath" ]
then
utilspath="/usr/bin"
# for standalone mode
if [ ! -e "$utilspath/sqltocsv" -o ! -e "$utilspath/isqlreq" ]
then
utilspath="$scriptdir/utils"
fi
fi
tablegenpath="/usr/bin/tablegen"
cmd="cat '$1' | awk -f '$scriptdir/error.awk' \
-f '$scriptdir/sources.awk' -f '$scriptdir/template.awk' \
-v 'A_scriptpath=$scriptdir' \
-v 'A_utilspath=$utilspath' -v 'A_tablegenpath=$tablegenpath'"
if [ $# -eq 3 ]
then
cmd="$cmd -v 'A_source=$3'"
fi
res="/tmp/res_$$.html"
rmcmd="$rmcmd $res"
eval $cmd >"$res"
if [ $? -ne 0 ]
then
exit 1
fi
cat "$res"
if [ $? -ne 0 ]
then
exit 1
fi
exit 0