Skip to content

Commit

Permalink
Detect Docker robustly
Browse files Browse the repository at this point in the history
"&> /dev/null" works as a redirection from stdout/stderr to /dev/null
in Bash but not in POSIX shell (considered as an asynchronous execution
and the result of the "command" command cannot be retrieved).

As a result, it always assumes that Docker always exists.

This commit makes the redirection robust and portable (makes it possible
to detect "no Docker" condition correctly).

Signed-off-by: Tsukasa OI <research_trasio@irq.a4lg.com>
  • Loading branch information
a4lg committed Sep 8, 2023
1 parent deebd2c commit 26fbafb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ all: build

build:
@echo "Checking if Docker is available..."
@if command -v docker &> /dev/null ; then \
@if command -v docker >/dev/null 2>&1 ; then \
echo "Docker is available, building inside Docker container..."; \
$(MAKE) build-container; \
else \
Expand All @@ -62,4 +62,4 @@ build-no-container:
clean:
@echo "Cleaning up generated files..."
rm -f $(PDF_RESULT)
@echo "Cleanup completed."
@echo "Cleanup completed."

0 comments on commit 26fbafb

Please sign in to comment.