Skip to content

Commit 1ebdc2c

Browse files
committed
fix setup script to not exit calling shell
Replace `exit 1` to `return 1`, otherwise the entire shell (terminal tab) is closed on errors. Signed-off-by: Miroslav Bajtoš <[email protected]>
1 parent 809677b commit 1ebdc2c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

setup.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ docker -v > /dev/null 2>&1
3838
DOCKER_EXISTS=$?
3939
if [ "$DOCKER_EXISTS" -ne 0 ]; then
4040
printf "\n\n${CYAN}Status: ${PLAIN}${RED}Docker not found. Terminating setup.${PLAIN}\n\n"
41-
exit 1
41+
return 1
4242
fi
4343
printf "\n${CYAN}Found docker. Moving on with the setup.${PLAIN}\n"
4444

@@ -57,7 +57,7 @@ printf "\n${RED}>> Starting the postgresql container${PLAIN} ${GREEN}...${PLAIN}
5757
CONTAINER_STATUS=$(docker run --name $POSTGRESQL_CONTAINER -e POSTGRES_USER=$USER -e POSTGRES_PASSWORD=$PASSWORD -p $PORT:5432 -d postgres:latest 2>&1)
5858
if [[ "$CONTAINER_STATUS" == *"Error"* ]]; then
5959
printf "\n\n${CYAN}Status: ${PLAIN}${RED}Error starting container. Terminating setup.${PLAIN}\n\n"
60-
exit 1
60+
return 1
6161
fi
6262
docker cp ./test/schema.sql $POSTGRESQL_CONTAINER:/home/ > /dev/null 2>&1
6363
printf "\n${CYAN}Container is up and running.${PLAIN}\n"
@@ -91,7 +91,7 @@ while [ "$OUTPUT" -ne 0 ] && [ "$TIMEOUT" -gt 0 ]
9191

9292
if [ "$TIMEOUT" -le 0 ]; then
9393
printf "\n\n${CYAN}Status: ${PLAIN}${RED}Failed to export schema. Terminating setup.${PLAIN}\n\n"
94-
exit 1
94+
return 1
9595
fi
9696
printf "\n${CYAN}Successfully exported schema to database.${PLAIN}\n"
9797

@@ -102,7 +102,7 @@ docker exec -it $POSTGRESQL_CONTAINER /bin/sh -c "psql -U $USER -c 'CREATE DATAB
102102
CREATE_DATABASE=$?
103103
if [ "$CREATE_DATABASE" -ne 0 ]; then
104104
printf "\n\n${CYAN}Status: ${PLAIN}${RED}Error creating database: $DATABASE. Terminating setup.${PLAIN}\n\n"
105-
exit 1
105+
return 1
106106
fi
107107
printf "\n${CYAN}Database created.${PLAIN}\n"
108108

0 commit comments

Comments
 (0)