Skip to content

Commit 27afddf

Browse files
committed
[Docker] Updated bash.sh to use more readable syntax.
Expanding arrays using `"${ARR[@]-}"` instead of `${ARR[@]+"${ARR[@]}"}`. This is more vulnerable to typos in the variable name, but much more readable and much less vulnerable to typos in the special characters.
1 parent 8c8a5a6 commit 27afddf

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docker/bash.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ if [[ -z "${DOCKER_IMAGE_NAME}" ]]; then
222222
show_usage >&2
223223
fi
224224

225-
if [[ ${COMMAND[@]+"${COMMAND[@]}"} = bash ]]; then
225+
if [[ "${COMMAND[@]-}" = bash ]]; then
226226
INTERACTIVE=true
227227
USE_NET_HOST=true
228228
fi
@@ -297,7 +297,7 @@ if ${INTERACTIVE}; then
297297
fi
298298

299299
# Expose external directories to the docker container
300-
for MOUNT_DIR in ${MOUNT_DIRS[@]+"${MOUNT_DIRS[@]}"}; do
300+
for MOUNT_DIR in "${MOUNT_DIRS[@]-}"; do
301301
DOCKER_MOUNT+=( --volume "${MOUNT_DIR}:${MOUNT_DIR}" )
302302
done
303303

@@ -369,20 +369,20 @@ echo "REPO_DIR: ${REPO_DIR}"
369369
echo "DOCKER CONTAINER NAME: ${DOCKER_IMAGE_NAME}"
370370
echo ""
371371

372-
echo Running \'${COMMAND[@]+"${COMMAND[@]}"}\' inside ${DOCKER_IMAGE_NAME}...
372+
echo "Running '${COMMAND[@]-}' inside ${DOCKER_IMAGE_NAME}..."
373373

374374
DOCKER_CMD=(${DOCKER_BINARY} run
375-
${DOCKER_FLAGS[@]+"${DOCKER_FLAGS[@]}"}
376-
${DOCKER_ENV[@]+"${DOCKER_ENV[@]}"}
377-
${DOCKER_MOUNT[@]+"${DOCKER_MOUNT[@]}"}
378-
${DOCKER_DEVICES[@]+"${DOCKER_DEVICES[@]}"}
375+
"${DOCKER_FLAGS[@]-}"
376+
"${DOCKER_ENV[@]-}"
377+
"${DOCKER_MOUNT[@]-}"
378+
"${DOCKER_DEVICES[@]-}"
379379
"${DOCKER_IMAGE_NAME}"
380380
bash --login /docker/with_the_same_user
381-
${COMMAND[@]+"${COMMAND[@]}"}
381+
"${COMMAND[@]-}"
382382
)
383383

384384
if ${DRY_RUN}; then
385-
echo ${DOCKER_CMD[@]+"${DOCKER_CMD[@]}"}
385+
echo "${DOCKER_CMD[@]-}"
386386
else
387-
${DOCKER_CMD[@]+"${DOCKER_CMD[@]}"}
387+
"${DOCKER_CMD[@]-}"
388388
fi

0 commit comments

Comments
 (0)