Skip to content

Commit 8cf7db7

Browse files
authored
Run script allows empty docker_args (#2053)
Currently when using `bazel run` on a docker image, I get: ``` /[redacted].executable: line 281: docker_args[@]: unbound variable ``` Alternatively, we could just `set +u` before execing docker.
1 parent bd4014a commit 8cf7db7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

container/incremental_load.sh.tpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,17 @@ if [[ "%{run}" == "True" ]]; then
283283
# We can clean up before we exec docker, since the exit handler will no longer run.
284284
cleanup
285285

286+
# Bash treats empty arrays as unset variables for the purposes of `set -u`, so we only
287+
# conditionally add these arrays to our args.
288+
args=(%{run_statement})
289+
if [[ ${#docker_args[@]} -gt 0 ]]; then
290+
args+=("${docker_args[@]}")
291+
fi
292+
args+=("%{run_tag}")
293+
if [[ ${#container_args[@]} -gt 0 ]]; then
294+
args+=("${container_args[@]}")
295+
fi
296+
286297
# This generated and injected by docker_*.
287-
eval exec %{run_statement} "${docker_args[@]}" "%{run_tag}" "${container_args[@]:-}"
298+
eval exec "${args[@]}"
288299
fi

0 commit comments

Comments
 (0)