From 182ae4a50ab5cb3b2af4f5be806724d57949c931 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Tue, 23 Jun 2015 23:41:34 +0200 Subject: [PATCH 1/3] Support config variables containing `\n` --- plugins/config/commands | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/config/commands b/plugins/config/commands index 348ca4bba..1028a7bd9 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -137,7 +137,7 @@ 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=$(echo "${ENV_TEMP}" | sed "/^export $KEY=/ d") ENV_TEMP="${ENV_TEMP}\nexport $KEY='$VALUE'" ENV_ADD=$(echo -e "${ENV_ADD}" | sed "/^$KEY=/ d") ENV_ADD="${ENV_ADD}$ From 0da389e8afa5fce2a1c9259000aa4399e658c543 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Tue, 23 Jun 2015 23:53:10 +0200 Subject: [PATCH 2/3] Further fixes for config values containing newlines. --- plugins/config/commands | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/config/commands b/plugins/config/commands index 1028a7bd9..71e065c75 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -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 @@ -138,7 +138,8 @@ case "$1" in if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then RESTART_APP=true ENV_TEMP=$(echo "${ENV_TEMP}" | sed "/^export $KEY=/ d") - ENV_TEMP="${ENV_TEMP}\nexport $KEY='$VALUE'" + ENV_TEMP="${ENV_TEMP} +export $KEY='$VALUE'" ENV_ADD=$(echo -e "${ENV_ADD}" | sed "/^$KEY=/ d") ENV_ADD="${ENV_ADD}$ ${var}" From b40a86a2fc865d22c8b33f1468f27fde138a4c00 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Wed, 24 Jun 2015 11:22:48 +0200 Subject: [PATCH 3/3] Add a testcase --- tests/unit/config.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/config.bats b/tests/unit/config.bats index e68860e9b..187f90946 100644 --- a/tests/unit/config.bats +++ b/tests/unit/config.bats @@ -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" {