Open profnandaa opened 2 months ago
It can also be reproduced on Linux:
$ cat Dockerfile
FROM alpine
RUN echo mkdir C:\another\sample
RUN echo mkdir C:\\another\\sample
$ docker build -t backslash-test --no-cache .
[+] Building 0.8s (7/7) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 118B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.2s
=> CACHED [1/3] FROM docker.io/library/alpine@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5 0.0s
=> [2/3] RUN echo mkdir C:anothersample 0.2s
=> [3/3] RUN echo mkdir C:\another\sample 0.2s
=> exporting to image 0.1s
=> => exporting layers 0.1s
=> => writing image sha256:cfbd890f4a908e48975d6c462a8b7b447effe943208c64625f2e0601942af236 0.0s
=> => naming to docker.io/library/backslash-test 0.0s
@ardrabczyk -- good catch, thanks! Updated the title and description.
I have narrowed down to this, frontend/dockerfile/dockerfile2llb/convert.go:2055
> github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb.processCmdEnv() C:/dev/buildkit/frontend/dockerfile/dockerfile2llb/convert.go:2057 (PC: 0x238dec1)
2055: func processCmdEnv(shlex *shell.Lex, cmd string, env shell.EnvGetter) string {
2056: w, _, err := shlex.ProcessWord(cmd, env)
=>2057: if err != nil {
2058: return cmd
2059: }
2060: return w
2061: }
2062:
(dlv) p cmd
"RUN echo C:\\hello\\world\\path"
(dlv) p w
"RUN echo C:helloworldpath"
~~~~~~~~~~~^^--- backslashes being stripped off by the lexer.
(dlv)
I'm not really conversant with this lexer, will appreciate any tips? @tonistiigi
However, prints when escaped or put within
".."
:Minimal repro dockerfile:
Result:
With classic
docker build
:Result: