Skip to content

Commit a4f268a

Browse files
committed
only use -it on ttys
1 parent c008a25 commit a4f268a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,17 @@ define user_confirm
187187
fi
188188
endef
189189

190+
# https://stackoverflow.com/questions/4251559/how-can-i-tell-if-a-makefile-is-being-run-from-an-interactive-shell
191+
INTERACTIVE:=$(shell [ -t 0 ] && echo 1)
192+
ifdef INTERACTIVE
193+
DOCKER_OPTIONS="-it"
194+
else
195+
DOCKER_OPTIONS=""
196+
endif
197+
190198
# $(call DOCKER, image, command)
191199
define DOCKER
192-
docker run -it --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 -w /app -v $(PWD):/app -v $(GOPATH):/go --init $(1) /bin/bash -c '$(2)'
200+
docker run "$(DOCKER_OPTIONS)" --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 -w /app -v $(PWD):/app -v $(GOPATH):/go --init $(1) /bin/bash -c '$(2)'
193201
endef
194202

195203
ifeq ($(BUILD_IN_DOCKER),y)
@@ -213,6 +221,7 @@ else
213221
PATHSEP = :
214222
endif
215223

224+
216225
v_at_0 = yes
217226
v_at_ = $(v_at_1)
218227
quiet := $(v_at_$(V))

0 commit comments

Comments
 (0)