Created
August 5, 2019 11:50
-
-
Save philwo/c4aa06a851c775731474417546f0a6a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
unset IFS | |
args=() | |
found="no" | |
function add_env_flags() { | |
# Add an --action_env=$ENV flag for every environment variable. | |
for var in $(compgen -e); do | |
args+=("--action_env=$var") | |
done | |
} | |
# Add all args from the command-line to the array. | |
for arg in "$@"; do | |
# Bazel uses the "--" to split flags and target names, so if it's present in the command-line | |
# args, we have to insert our flags before that separator. | |
if [[ $arg == "--" ]]; then | |
add_env_flags | |
found="yes" | |
fi | |
args+=("$arg") | |
done | |
# If there was no "--" separator, just add the --action_env= flags to the end of the command-line. | |
if [[ $found == "no" ]]; then | |
add_env_flags | |
fi | |
exec bazel "${args[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment