diff --git a/scripts/repository/binary_safe_diff.sh b/scripts/repository/binary_safe_diff.sh
index 1473e804..b51d31a6 100755
--- a/scripts/repository/binary_safe_diff.sh
+++ b/scripts/repository/binary_safe_diff.sh
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 diff "$@"
-if [ "$?" = "2" ]; then
+RES="$?"
+if [ "$RES" = "2" ]; then
   exit 1
 fi
+exit "$RES"