From c8621f777abc8ade97b0d93109c82d52837f1a1f Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Fri, 10 Nov 2023 16:27:06 +0100 Subject: [PATCH] prevent globing and word splitting --- compose/bin/docker-compose | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compose/bin/docker-compose b/compose/bin/docker-compose index e8285f16b..27e8a6993 100755 --- a/compose/bin/docker-compose +++ b/compose/bin/docker-compose @@ -6,16 +6,19 @@ else DOCKER_COMPOSE="docker-compose" fi -COMPOSE_FILES_LIST=("compose.yaml" "compose.healthcheck.yaml") +COMPOSE_FILES=("compose.yaml" "compose.healthcheck.yaml") if [ "$1" == "--no-dev" ]; then # ensure --no-dev parameter isn't passed to docker compose shift 1 else - COMPOSE_FILES_LIST+=("compose.dev.yaml") + COMPOSE_FILES+=("compose.dev.yaml") fi -# Combine files, prefix each with -f -COMPOSE_FILES="${COMPOSE_FILES_LIST[@]/#/'-f '}" +COMPOSE_FILES_PREFIXED=() -${DOCKER_COMPOSE} ${COMPOSE_FILES} "$@" +for file in "${COMPOSE_FILES[@]}"; do + COMPOSE_FILES_PREFIXED+=("-f" "$file") +done + +${DOCKER_COMPOSE} "${COMPOSE_FILES_PREFIXED[@]}" "$@"