From e1f6cea405f37eaed3bd1c1ae9f17af7f9e82eef Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Tue, 18 Dec 2018 01:01:35 -0800 Subject: [PATCH] Proper tty support for build.sh --- build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 6ec1cce..050fddb 100755 --- a/build.sh +++ b/build.sh @@ -5,8 +5,15 @@ set -e -x DIR=$(cd "$(dirname "$0")"; pwd -P) TOOLCHAIN_IMAGE="esp32-toolchain:latest" -BUILD_DIR="$DIR/cmake-build" +: ${BUILD_DIR:="$DIR/cmake-build"} DOCKERFILE="$DIR/Dockerfile" +DOCKER_RUN_FLAGS=(--interactive --rm) + +# if stdin is a terminal, tell docker to allocate a tty +if [ -t 0 ]; then + DOCKER_RUN_FLAGS+=(--tty) +fi + build_docker_container() { docker build -f "$DOCKERFILE" -t "$TOOLCHAIN_IMAGE" "$DIR" @@ -16,7 +23,7 @@ build_docker() { build_docker_container docker run \ --volume="$DIR:/esp/uas-ugv" \ - --interactive --tty --rm \ + "${DOCKER_RUN_FLAGS[@]}" \ "$TOOLCHAIN_IMAGE" \ /esp/uas-ugv/build.sh cmake "$@" }