-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild
executable file
·32 lines (28 loc) · 834 Bytes
/
build
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
#!/bin/sh
set -e
if [ "$1" == "-h" -o "$1" == "--help" -o $# != 1 ]; then
echo "Usage: ./build spickzettel | ./build --all | ./build --changed"
echo " --all builds all cheat-sheats"
echo " --changed builds only the cheat-sheats that have been changed according to git"
exit 0
fi
function build() {
mkdir -p output
if pdflatex -interaction=nonstopmode -output-directory output "$1.tex"; then
cp "output/$1.pdf" .
else
echo "\n === ERROR WHILE COMPILING (SEE ABOVE) ===" >&1
exit 1
fi
}
if [ "$1" == "--all" -o "$1" == "-a" ]; then
for file in *.tex; do
build "${file%.*}"
done
elif [ "$1" == "--changed" -o "$1" == "-c" ]; then
for file in $(git status --porcelain | awk '(($1 == "M") && match($2, /\.tex$/)) { print $2 }'); do
build "${file%.*}"
done
else
build "${1%.*}"
fi