Skip to content

Commit d8cb761

Browse files
committed
Eval exit code of wrong $(shell) cmds
1 parent 0690177 commit d8cb761

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Makefile.docker

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ docker-load:
198198
# Helper Targets
199199
# -------------------------------------------------------------------------------------------------
200200
.PHONY: docker-pull-base-image
201-
_DOCKER_PULL_BASE_IMAGES_FOUND = $(shell grep FROM $(DIR)/$(FILE) | sed 's/^FROM\s*//g' | sed 's/\s.*$$//g' | sort -u )
201+
_DOCKER_PULL_BASE_IMAGES_FOUND = $(shell \
202+
if [ ! -f "$(DIR)/$(FILE)" ]; then \
203+
echo "Error, Dockerfile not found in: $(DIR)/$(FILE)" >&2; \
204+
exit 1; \
205+
fi; \
206+
grep FROM $(DIR)/$(FILE) | sed 's/^FROM\s*//g' | sed 's/\s.*$$//g' | sort -u \
207+
)
202208
DOCKER_PULL_VARIABLES = "VERSION=$(VERSION)"
203209
docker-pull-base-image:
204210
@echo "################################################################################"
@@ -209,6 +215,9 @@ docker-pull-base-image:
209215
@if [ -n $(DOCKER_PULL_VARIABLES) ];then for e in $(DOCKER_PULL_VARIABLES);do export "$${e}";done;fi; echo "Images Found: $(_DOCKER_PULL_BASE_IMAGES_FOUND)"
210216
@if [ -n $(DOCKER_PULL_VARIABLES) ];then for e in $(DOCKER_PULL_VARIABLES);do export "$${e}";done;fi; echo "Images Ignore: $(DOCKER_PULL_BASE_IMAGES_IGNORE)"
211217
@echo
218+
@if [ "$(.SHELLSTATUS)" != "0" ]; then \
219+
exit 1; \
220+
fi
212221
# These variables will be exported to the shell
213222
@if [ -n $(DOCKER_PULL_VARIABLES) ];then for e in $(DOCKER_PULL_VARIABLES);do export "$${e}";done;fi; \
214223
echo $(_DOCKER_PULL_BASE_IMAGES_FOUND) | sed 's/\s/\n/g' | while read -r line; do \

0 commit comments

Comments
 (0)