Skip to content

Commit de35cf6

Browse files
committed
I just learned about trap
Automatically exit on failure
1 parent 700519d commit de35cf6

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

.travis.scripts/compile.sh

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
#!/bin/bash
2+
trap abort_on_failure ERR
3+
4+
abort_on_failure () {
5+
echo "Last command failed, exising"
6+
exit 42;
7+
}
28

39
MONGOC_VERSION=master
410
LIBBSON_VERSION=master
511
LCOV_VERSION=1.11
612

713

8-
abort_on_failure () {
9-
if [ $1 -ne 0 ]; then
10-
echo "Last command failed, exising"
11-
exit 42;
12-
fi
13-
}
14-
15-
1614
sudo apt-get install gdb
1715
mkdir tmp-lcov
1816
pushd tmp-lcov
@@ -24,46 +22,34 @@ popd
2422
pushd src
2523
if [ "$MONGOC_VERSION" = "master" ]; then
2624
wget -O libmongoc.tar.gz https://github.com/mongodb/mongo-c-driver/archive/master.tar.gz
27-
abort_on_failure $?
2825
else
2926
wget -O libmongoc.tar.gz https://github.com/mongodb/mongo-c-driver/releases/download/${MONGOC_VERSION}/mongo-c-driver-${MONGOC_VERSION}.tar.gz
30-
abort_on_failure $?
3127
fi
3228

3329

3430
mkdir libmongoc
3531
pushd libmongoc
3632
tar zxf ../libmongoc.tar.gz --strip-components=1
37-
abort_on_failure $?
3833

3934
pushd src
4035
if [ "$LIBBSON_VERSION" = "master" ]; then
4136
wget -O libbson.tar.gz https://github.com/mongodb/libbson/archive/master.tar.gz
42-
abort_on_failure $?
4337
else
4438
wget -O libbson.tar.gz https://github.com/mongodb/libbson/releases/download/${LIBBSON_VERSION}/libbson-${LIBBSON_VERSION}.tar.gz
45-
abort_on_failure $?
4639
fi
4740

4841
pushd libbson
4942
tar zxf ../libbson.tar.gz --strip-components=1
5043

5144
./autogen.sh --enable-debug --enable-debug-symbols=full --disable-ssl --enable-trace --quiet
52-
abort_on_failure $?
5345
popd
5446

5547
popd # src
5648

5749
./autogen.sh --enable-debug --enable-debug-symbols=full --with-libbson=bundled --disable-ssl --enable-trace --quiet
58-
abort_on_failure $?
59-
60-
abort_on_failure $?
6150

6251
make -s -j2 all
63-
abort_on_failure $?
64-
6552
sudo make install
66-
abort_on_failure $?
6753

6854
popd # libmongoc
6955
popd # src
@@ -72,13 +58,8 @@ popd # src
7258

7359
phpize
7460
./configure --enable-coverage
75-
abort_on_failure $?
76-
7761
make all
78-
abort_on_failure $?
79-
8062
sudo make install
81-
abort_on_failure $?
8263

8364

8465

0 commit comments

Comments
 (0)