diff --git a/bash-env-json b/bash-env-json index 0164ba9..dc83035 100755 --- a/bash-env-json +++ b/bash-env-json @@ -22,7 +22,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -VERSION="0.10.0a1" +VERSION="0.10.0a2" USAGE="bash-env-json [--help] [--shellfns ] [path]" shopt -s extglob @@ -63,7 +63,7 @@ function capture() { function emit_value() { # `jq -R` produces nothing on empty input, but we want "" if test -n "$1"; then - echo -n "$1" | _jq -R + echo -n "$1" | _jq -Rs else echo -n '""' fi diff --git a/tests.bats b/tests.bats index 99ede72..243e390 100755 --- a/tests.bats +++ b/tests.bats @@ -13,7 +13,7 @@ function test_case() { echo "$@" # sort and remove `meta` before comparison with expected output - bash-env-json "$@" "$_test_file" | jq --sort-keys 'del(.meta)' | diff -w - "$_expected_output" + ./bash-env-json "$@" "$_test_file" | jq --sort-keys 'del(.meta)' | diff -w - "$_expected_output" } @test "empty" { @@ -40,11 +40,14 @@ function test_case() { test_case "Ming's menu of (merciless) monstrosities" } +@test "multiline-string" { + test_case multiline-string +} + @test "error" { test_case error } - @test "shell-function-error" { test_case shell-function-error --shellfns f } diff --git a/tests/multiline-string.env b/tests/multiline-string.env new file mode 100644 index 0000000..8560b37 --- /dev/null +++ b/tests/multiline-string.env @@ -0,0 +1,3 @@ +export MULTILINE="a +b +c" diff --git a/tests/multiline-string.json b/tests/multiline-string.json new file mode 100644 index 0000000..0c521cb --- /dev/null +++ b/tests/multiline-string.json @@ -0,0 +1,6 @@ +{ + "env": { + "MULTILINE": "a\nb\nc" + }, + "shellvars": { } +} diff --git a/tests/multiline-string.setup.env b/tests/multiline-string.setup.env new file mode 100644 index 0000000..632b83d --- /dev/null +++ b/tests/multiline-string.setup.env @@ -0,0 +1 @@ +unset MULTILINE