1
0
Fork 0

download_and_compile.sh: add safety net in _cleanup()

Make sure $INSTALL_DIR is really a harmless 'install' directory before
calling 'rm -rf' on it.
This commit is contained in:
Florent Rougon 2020-06-29 16:04:23 +02:00
parent 3099633675
commit 9f710a8c84

View file

@ -218,8 +218,14 @@ function _cleanup(){
fgdata_moved=1
fi
_printLog "Deleting install directories ($INSTALL_DIR)..."
rm -rf "$INSTALL_DIR"
if [[ "$(basename "$INSTALL_DIR")" -eq "install" ]]; then
_printLog "Deleting install directories ($INSTALL_DIR)..."
rm -rf "$INSTALL_DIR"
else
_printLog "${PROGNAME}: unexpected value for \$INSTALL_DIR: '$INSTALL_DIR'."
_printLog "Refusing to recursively delete it. Aborting; please report."
exit 1
fi
if [[ $fgdata_moved -eq 1 ]]; then
mkdir -p "$INSTALL_DIR_FGFS"