-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgift-for-html.sh
executable file
·61 lines (48 loc) · 1.18 KB
/
gift-for-html.sh
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
56
57
58
59
60
61
#!/usr/bin/env bash
# name: gift-for-html
# author: S. Kramm
# home: https://github.com/skramm/gift-for-html
# here, you can define the source file extension
SOURCE_EXT=src
# program location
LOCATION=/usr/local/bin
if [ "$1" = "" ]
then
echo "No input file given, exit !"
exit -1
fi
# https://stackoverflow.com/a/965069/193789
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
if [ "$extension" != "$SOURCE_EXT" ]; then
echo "Wrong input file, please give me a \".$SOURCE_EXT\" file, exit !"
exit -1
fi
#echo " -Step 0"
#awk -f process_src2gift_0.awk "$1"
#if [ $? != 0 ]; then
# echo "Error: awk failure at step 0"
# exit 1
#fi
#exit 0
echo " -Step 1"
awk -f $LOCATION/process_src2gift_1.awk "$1" >"/tmp/$filename.tmp1"
if [ $? != 0 ]; then
echo "Error: awk failure at step 1"
exit 1
fi
echo " -Step 2"
awk -f $LOCATION/process_src2gift_2.awk "/tmp/$filename.tmp1" >"/tmp/$filename.tmp2"
if [ $? != 0 ]; then
echo "Error: awk failure at step 2"
exit 2
fi
echo " -Step 3"
awk -f $LOCATION/process_src2gift_3.awk "/tmp/$filename.tmp2" >"$filename.gift"
if [ $? != 0 ]; then
echo "Error: awk failure at step 3"
exit 3
fi
#rm /tmp/$filename.tmp
echo " -Done"