-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·121 lines (99 loc) · 1.97 KB
/
entrypoint.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
USAGE="$(basename "$0") [-h] [-i index] [-o index] [-s] [-b] [-c]
where:
-h, --help
Display this help.
-i, --input
Set input TeX file (default ./index).
File must be .tex extension.
-o, --output
Set output PDF file (default is same as input).
-s, --silent
Won't display anything.
-b, --biber
Run biber as well.
-c, --clear
Clear all temporary files.
(c) 2019-2020 by m1k1o"
INPUT="index"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
echo "$USAGE" > /dev/stderr
exit
;;
-i|--input)
INPUT="$(basename "$2" .tex)"
cd "$(dirname "$2")"
shift # past argument
shift # past value
;;
-o|--output)
OUTPUT="$2"
shift # past argument
shift # past value
;;
-s|--silent)
SILENT="true"
shift # past argument
;;
-b|--biber)
BIBER="true"
shift # past argument
;;
-c|--clear)
CLEAR="true"
shift # past argument
;;
*) # unknown option
echo "Unknown option $1" > /dev/stderr
exit
;;
esac
done
if [[ "$SILENT" != "true" ]]
then
OUT="/dev/stderr"
else
OUT="/dev/null"
fi
echo "
Running with parameters:
PWD = ${PWD}
INPUT = ${INPUT}
OUTPUT = ${OUTPUT}
SILENT = ${SILENT}
BIBER = ${BIBER}
CLEAR = ${CLEAR}
" > "$OUT"
function runlatex {
pdflatex -interaction nonstopmode "$INPUT".tex > "$OUT"
}
function runbiber {
biber "$INPUT" > "$OUT"
}
# Run LaTeX to generate the AUX file. It adds a line every time it finds a cite.
runlatex &&
# After using biber, make PDF 2x
if [[ "$BIBER" == "true" ]]
then
# Run BibTeX (executable: biber) to generate the BBL (from the AUX lines).
runbiber &&
# Then run LaTeX again, which will include the BBL.
runlatex
fi &&
# Then run LaTeX again to make any updates corresponding to including the possibly massive BBL.
runlatex
# Clean files generated by
if [[ "$CLEAR" == "true" ]]
then
rm -f .log *.out *.log *.dvi *.aux *.toc *.bbl *.blg *.bcf *.run.xml 2> /dev/null
fi
# Move to output
if [[ ! -z "$OUTPUT" ]]
then
mv "$INPUT".pdf "$OUTPUT"
fi