Skip to content

Commit

Permalink
new .env parser that handles spaces. closes #188
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelshobbs committed Nov 13, 2016
1 parent abc8a87 commit 465bbe1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions buildpacks/buildpack-java/tests/java-jetty/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TEST1=The big brown fox1
TEST2="The big brown fox2"
TEST3='The big brown fox3'
export TEST4=The big brown fox4
export TEST5="The big brown fox5"
export TEST6='The big brown fox6'
24 changes: 22 additions & 2 deletions include/buildpack.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@

_envfile-parse() {
declare desc="Parse input into shell export commands"
local key
local value
while read line || [[ -n "$line" ]]; do
[[ "$line" =~ ^#.* ]] && continue
key=${line%%=*}
key=${key#*export }
value=${line#*=}
case "$value" in
\'*|\"*)
value=${value}
;;
*)
value=\"${value}\"
;;
esac
echo "export ${key}=${value}"
done <<< "$(cat)"
}

buildpack-build() {
declare desc="Build an application using installed buildpacks"
ensure-paths
Expand Down Expand Up @@ -88,10 +109,9 @@ buildpack-setup() {
export CURL_CONNECT_TIMEOUT="30"
export CURL_TIMEOUT="180"


# Buildstep backwards compatibility
if [[ -f "$app_path/.env" ]]; then
source "$app_path/.env"
eval $(cat "$app_path/.env" | _envfile-parse)
fi
}

Expand Down
1 change: 0 additions & 1 deletion include/herokuish.bash
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ herokuish-test() {
echo "::: TEST FINISHED :::"
}


main() {
set -eo pipefail; [[ "$TRACE" ]] && set -x

Expand Down

0 comments on commit 465bbe1

Please sign in to comment.