-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild
executable file
·42 lines (35 loc) · 962 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
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
# Update publications list using Bibble.
# Stop on errors
set -Eeuo pipefail
# Parse arguments
if [ "$#" -eq 0 ]; then
INDEXHTML="docs/index.html"
elif [ "$#" -eq 1 ]; then
INDEXHTML="$1"
else
echo "Usage: $0 [INDEXHTML]"
exit 1
fi
# Sanity checks
if ! test -e $INDEXHTML; then
echo "Error: file does not exist: $INDEXHTML"
exit 1
fi
if ! grep -q "BEGIN BIBBLE" $INDEXHTML; then
echo "Error: can't find 'BEGIN BIBBLE' in $INDEXHTML"
exit 1
fi
if ! grep -q "END BIBBLE" $INDEXHTML; then
echo "Error: can't find 'END BIBBLE' in $INDEXHTML"
exit 1
fi
# Copy everything up to and including "BEGIN BIBBLE"
sed '/BEGIN BIBBLE/q' $INDEXHTML > $INDEXHTML.tmp
# Generate new publications list and insert
bibble publications_database.bib publications_template.html >> $INDEXHTML.tmp
# Copy everything after and including "END BIBBLE"
sed -ne '/END BIBBLE/,$ p' $INDEXHTML >> $INDEXHTML.tmp
# Clean up
mv $INDEXHTML.tmp $INDEXHTML