Skip to content

Commit

Permalink
Run script allows empty docker_args (#2053)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
illicitonion authored Apr 19, 2022
1 parent bd4014a commit 8cf7db7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion container/incremental_load.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,17 @@ if [[ "%{run}" == "True" ]]; then
# We can clean up before we exec docker, since the exit handler will no longer run.
cleanup

# Bash treats empty arrays as unset variables for the purposes of `set -u`, so we only
# conditionally add these arrays to our args.
args=(%{run_statement})
if [[ ${#docker_args[@]} -gt 0 ]]; then
args+=("${docker_args[@]}")
fi
args+=("%{run_tag}")
if [[ ${#container_args[@]} -gt 0 ]]; then
args+=("${container_args[@]}")
fi

# This generated and injected by docker_*.
eval exec %{run_statement} "${docker_args[@]}" "%{run_tag}" "${container_args[@]:-}"
eval exec "${args[@]}"
fi

0 comments on commit 8cf7db7

Please sign in to comment.