Merge pull request #1245 from arthurschreiber/patch-1

Support config variables containing `\n`
This commit is contained in:
Michael Hobbs
2015-06-24 12:32:47 -07:00
2 changed files with 9 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ config_styled_hash () {
config_write() {
ENV_TEMP="$1"
echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP
echo "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP
if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then
cp -f $ENV_FILE_TEMP $ENV_FILE
chmod 600 $ENV_FILE
@@ -137,8 +137,9 @@ case "$1" in
if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then
RESTART_APP=true
ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $KEY=/ d")
ENV_TEMP="${ENV_TEMP}\nexport $KEY='$VALUE'"
ENV_TEMP=$(echo "${ENV_TEMP}" | sed "/^export $KEY=/ d")
ENV_TEMP="${ENV_TEMP}
export $KEY='$VALUE'"
ENV_ADD=$(echo -e "${ENV_ADD}" | sed "/^$KEY=/ d")
ENV_ADD="${ENV_ADD}$
${var}"

View File

@@ -20,7 +20,7 @@ teardown() {
}
@test "(config) config:get" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" test_var3=\"with\\nnewline\"
echo "output: "$output
echo "status: "$status
assert_success
@@ -28,6 +28,10 @@ teardown() {
echo "output: "$output
echo "status: "$status
assert_output 'hello world'
run dokku config:get $TEST_APP test_var3
echo "output: "$output
echo "status: "$status
assert_output 'with\nnewline'
}
@test "(config) config:unset" {