Early exit if can't read file

This commit is contained in:
Anes Belfodil
2021-01-21 10:45:30 -05:00
parent 1b9008040e
commit dfc3a38db1

View File

@ -5,6 +5,7 @@ for env_var in $FILE_ENV_VARS; do
var_name="$(echo $env_var | grep -o '.*__FILE=' | sed 's/__FILE=//g')" var_name="$(echo $env_var | grep -o '.*__FILE=' | sed 's/__FILE=//g')"
file_path="$(echo $env_var | grep -o '__FILE=.*' | sed 's/__FILE=//g')" file_path="$(echo $env_var | grep -o '__FILE=.*' | sed 's/__FILE=//g')"
file_content="$(cat $file_path)" file_content="$(cat $file_path)"
[[ ! $? -eq 0 ]] && exit 1 # Exit if last command failed
new_var="$(echo $var_name=$file_content)" new_var="$(echo $var_name=$file_content)"
export $(echo $new_var | xargs) export $(echo $new_var | xargs)
done done