From ed3bc3b9864dff42a7949aa9202ea242e9ed0a9b Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Thu, 19 Feb 2015 16:27:20 -0800 Subject: [PATCH] Add a ENV tests with special chars in the values Tests a little bit of escaping quotes too See https://github.com/docker/docker/pull/10431#issuecomment-75163177 Signed-off-by: Doug Davis --- integration-cli/docker_cli_build_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index f29eb8652b..a2b75bfa0a 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -3728,6 +3728,9 @@ ENV FROM hello/docker/world ENV TO /docker/world/hello ADD $FROM $TO RUN [ "$(cat $TO)" = "hello" ] +ENV abc=def +ENV ghi=$abc +RUN [ "$ghi" = "def" ] ` ctx, err := fakeContext(dockerfile, map[string]string{ "hello/docker/world": "hello", @@ -3770,6 +3773,26 @@ ENV abc 'yyy' RUN [ $abc = \'yyy\' ] ENV abc= RUN [ "$abc" = "" ] + +# use grep to make sure if the builder substitutes \$foo by mistake +# we don't get a false positive +ENV abc=\$foo +RUN [ "$abc" = "\$foo" ] && (echo "$abc" | grep foo) +ENV abc \$foo +RUN [ "$abc" = "\$foo" ] && (echo "$abc" | grep foo) + +ENV abc=\'foo\' +RUN [ "$abc" = "'foo'" ] +ENV abc=\"foo\" +RUN [ "$abc" = "\"foo\"" ] +ENV abc "foo" +RUN [ "$abc" = "\"foo\"" ] +ENV abc 'foo' +RUN [ "$abc" = "'foo'" ] +ENV abc \'foo\' +RUN [ "$abc" = "\\'foo\\'" ] +ENV abc \"foo\" +RUN [ "$abc" = "\\\"foo\\\"" ] ` ctx, err := fakeContext(dockerfile, map[string]string{ "hello/docker/world": "hello",