diff --git a/compile b/compile
index 8eeced8538a1ebb5891e7227430cf756854ce7f6..bdc095afe6862075ab713e77eaf29a130dddd72b 100755
--- a/compile
+++ b/compile
@@ -12,23 +12,28 @@ ARCH="$(uname -m)"
 if [ "$ARCH" = "x86_64" ]
 then
 	echo "x64 arch"
-	./devTools/tweeGo/tweego_nix64 -o bin/FC_pregmod.html src/
+	./devTools/tweeGo/tweego_nix64 -o bin/FC_pregmod.html src/ || build_failed="true"
 elif echo "$ARCH" | grep -Ee '86$' > /dev/null
 then
 	echo "x86 arch"
-	./devTools/tweeGo/tweego_nix86 -o bin/FC_pregmod.html src/
+	./devTools/tweeGo/tweego_nix86 -o bin/FC_pregmod.html src/ || build_failed="true"
 elif echo "$ARCH" | grep -Ee '^arm' > /dev/null
 then
 	echo "arm arch"
 	# tweego doesn't provide arm binaries so you have to build it yourself
 	export TWEEGO_PATH=devTools/tweeGo/storyFormats
-	tweego -o bin/FC_pregmod.html src/
+	tweego -o bin/FC_pregmod.html src/ || build_failed="true"
 else
 	exit 2
 fi
 
-#Make the output prettier, replacing \t with a tab and \n with a newline
-sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".*$/s/\\n/\n/g'  bin/FC_pregmod.html
-
 # Revert AlphaDisclaimer for next compilation
 git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw
+
+if [ "$build_failed" = "true" ]
+then
+	exit 1
+fi
+
+#Make the output prettier, replacing \t with a tab and \n with a newline
+sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".*$/s/\\n/\n/g'  bin/FC_pregmod.html