From c88f29d67c447e3d66ed32139982044a9221290a Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Tue, 21 Aug 2018 21:02:35 -0500 Subject: [PATCH] more DRY re: env vars --- run.sh | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/run.sh b/run.sh index 8f72bfa..326d662 100755 --- a/run.sh +++ b/run.sh @@ -37,21 +37,22 @@ run_embark () { "${EMBARK_DOCKER_MOUNT_SOURCE}:${EMBARK_DOCKER_MOUNT_TARGET}" ) - if [[ -v LANG ]]; then - run_opts=( "${run_opts[@]}" "-e" "LANG" ) - fi - - if [[ -v LANGUAGE ]]; then - run_opts=( "${run_opts[@]}" "-e" "LANGUAGE" ) - fi - - if [[ -v LC_ALL ]]; then - run_opts=( "${run_opts[@]}" "-e" "LC_ALL" ) - fi - - if [[ -v TERM ]]; then - run_opts=( "${run_opts[@]}" "-e" "TERM" ) - fi + local env_var + for env_var in LANG \ + LANGUAGE \ + LC_ALL \ + TERM; + # do not alter indentation, tabs in lines below + do + local include_var=$(cat <<- ENV_VAR + if [[ -n $env_var && -v $env_var ]]; then + run_opts=( "${run_opts[@]}" "-e" "$env_var" ) + fi + ENV_VAR + ) + eval "$include_var" + done + # do not alter indentation, tabs in lines above if [[ $EMBARK_DOCKER_RUN_RM = true ]]; then run_opts=( "${run_opts[@]}" "--rm" )