-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommon.config
73 lines (66 loc) · 2.09 KB
/
common.config
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
62
63
64
65
66
67
68
69
70
71
72
73
##### CONSTS
DOCUMENTSROOT=./LaTex/documenti
PDFROOT=build-output
OUTPUT_ZIP=Documentazione.zip
RELEASE=Or-Bit
SPELLCHECK_DIR=spellcheck
##### FUNCTIONS
# requires 1 argument:
# -) path to a file
function getFileName {
if [ -z "$1" ] ; then
echo "Argument missing"
exit 2
fi
echo "$(basename "$1")"
}
function getFileNameWithoutExtension {
if [ -z "$1" ] ; then
echo "Argument missing"
exit 2
fi
temp="$(basename "$1")"
echo "${temp%.*}"
}
# requires 1 argument
# -) path to a file
function getLastDirectoryName {
if [ -z "$1" ] ; then
echo "Argument missing"
exit 2
fi
echo "$(basename "$(dirname "$1")")"
}
# requires 2 arguments:
# 1) indexfile (file *.config)
# 2) output folder
function buildFiles {
indexfile=$1
outputFolder=$2
# IFS='' prevents leading/trailing spaces from being trimmed
# -r prevents \ from being interpreted
# || [[ -n $line ]] prevents the last row from being ignored if it does not end with \n
while IFS='' read -r line || [[ -n "$line" ]]; do
# =~ matches the regex specified on the RIGHT into the LEFT "object"
# check if line is a comment and skip it
echo "$line"
if [[ $line =~ ^"#" ]] ; then
continue
# check if line corresponds to format: {doc name & folder}={output doc name}
elif [[ $line =~ ^([_[:alpha:]][_[:alnum:]]*)"="(.*) ]] ; then
inputDocName="${BASH_REMATCH[1]}"
outputDocName="${BASH_REMATCH[2]}"
if [[ $outputDocName =~ "Verbal.*" ]] ; then
mkdir -p "$outputFolder"/Verbali
outputDocName=Verbali/"$outputDocName"
fi
docPath="$DOCUMENTSROOT"/"$inputDocName"
./build-latex.sh "$docPath" "$inputDocName".tex "$outputFolder" "$outputDocName"
if [ "$?" -ne 0 ] ; then
echo "Error in building LaTeX: read the log file in "$outputFolder"/"$inputDocName".log for more details."
exit 666
fi
fi
continue
done < "$indexfile"
}