Skip to content

Commit 61a96f7

Browse files
committed
all.sh: Add error handling to the install script
1 parent 23ee4a3 commit 61a96f7

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

all.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22

3+
set -Eeuo pipefail
4+
35
MODULES=java.base,java.logging
46
OUTPUT=jpicoc
5-
VERSION=0.2
7+
VERSION=0.3
68
JARNAME=PiccodeScript-$VERSION-jar-with-dependencies.jar
79
JARDIR=target/
810

@@ -47,7 +49,7 @@ checkJarAndBuild() {
4749
log "Building from scratch."
4850
mvn package
4951
log "Verifying the compiler."
50-
./verify.sh
52+
./verify.sh
5153
fi
5254
}
5355

@@ -87,32 +89,39 @@ install() {
8789
}
8890

8991
verify() {
90-
./verify.sh
92+
./verify.sh
9193
}
9294

9395
finalCleanUp() {
94-
log "Final clean up"
95-
rm -rf $OUTPUT $APP_NAME $JARDIR
96-
log "Final clean up completed"
96+
log "Final clean up"
97+
rm -rf $OUTPUT $APP_NAME $JARDIR
98+
log "Final clean up completed"
9799
}
98100

99101
finalMessage() {
100-
log ""
101-
log "Please make sure to add $INSTALL/bin to your PATH"
102-
log "Try running picoc --version to test the installation"
103-
log "Run picoc --h for help and picoc run --repl for a quick repl session"
104-
log ""
105-
log "Thank you for installing PiccodeScript."
102+
log ""
103+
log "Please make sure to add $INSTALL/bin to your PATH"
104+
log "Try running picoc --version to test the installation"
105+
log "Run picoc --h for help and picoc run --repl for a quick repl session"
106+
log ""
107+
log "Thank you for installing PiccodeScript."
108+
}
109+
110+
handle_error() {
111+
log "Something went wrong"
112+
finalCleanUp
106113
}
107114

115+
trap handle_error ERR
116+
108117
main() {
109118
splash
110119
checkJarAndBuild
111120
checkAndClean
112121
buildImage
113122
install
114-
finalCleanUp
115-
finalMessage
123+
finalCleanUp
124+
finalMessage
116125
}
117126

118127
main

0 commit comments

Comments
 (0)