From 5a68998ba73856605f89b0edbb114cdca3ce0b28 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 14 Dec 2018 18:00:20 +0100 Subject: [PATCH] kas-docker: Allow passing multi-word variables into the container This is complex, not just because we are passing the arguments to the trace function, but already because they need to be protected in their structure when unrolling them at the top level. The trick seems to be using the argument list via set and "$@" to preserve the individual words. Due to the trace indirection, we additionally need the single quotes around the variable values. Signed-off-by: Jan Kiszka --- kas-docker | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kas-docker b/kas-docker index a12bc8a..45cb5fe 100755 --- a/kas-docker +++ b/kas-docker @@ -47,8 +47,8 @@ usage() trace() { - [ -n "${VERBOSE}" ] && echo "+ $*" - eval "$*" + [ -n "${VERBOSE}" ] && echo "+ ""$@" + eval "$@" } DOCKER_IMAGE=kasproject/kas @@ -178,13 +178,14 @@ if [ -n "${KAS_REPO_REF_DIR}" ]; then -e KAS_REPO_REF_DIR=${KAS_REPO_REF_DIR}" fi +set -- ${DOCKER_ARGS} + for var in SHELL TERM KAS_DISTRO KAS_MACHINE KAS_TARGET KAS_TASK \ http_proxy https_proxy ftp_proxy no_proxy; do if [ -n "$(eval echo \$${var})" ]; then - DOCKER_ARGS="${DOCKER_ARGS} \ - -e $var=$(eval echo \$${var})" + set -- "$@" -e "${var}='$(eval echo \$${var})'" fi done -trace docker run ${DOCKER_ARGS} ${ISAR_ARGS} ${USER_ARGS} \ +trace docker run "$@" ${ISAR_ARGS} ${USER_ARGS} \ ${DOCKER_IMAGE} ${CMD} ${KAS_FILE}