HEREDOC: Escaping `$` seems off
Description
Let's say we have dockerfile like:
FROM fedora:latest
ENV EXPAND_THIS_VAR=/correctly_expanded
COPY <<EOF /etc/profile.d/load-modules.sh
export MODULEPATH="\$MODULEPATH:$EXPAND_THIS_VAR/lmod"
EOF
CMD cat /etc/profile.d/load-modules.sh
The issue is that the $ sign is not escaped as expected
Describe the results you received:
$ podman run ...
export MODULEPATH="\$MODULEPATH:/correctly_expanded/lmod"
Describe the results you expected:
$ podman run ...
export MODULEPATH="$MODULEPATH:/correctly_expanded/lmod"
Output of podman version if reporting a podman build issue:
Client: Podman Engine
Version: 4.9.3
API Version: 4.9.3
Go Version: go1.21.7
Built: Mon Feb 19 16:41:34 2024
OS/Arch: linux/amd64
A friendly reminder that this issue had no activity for 30 days.
Maybe #5473
A friendly reminder that this issue had no activity for 30 days.
FWIW I hit this issue today (or something very simliar) after writing some heredocs that "worked" on podman 4.9.4 but not on 5.2.1, strangely the buildah version is the same 1.37.0. But I'm running podman build.
On 5.2.1 I was unable to get the escaping to work at all in the COPY heredoc, and it sort of worked with converting all $ to \$ if was a RUN heredoc. Because I wanted the container file to work across multiple versions and I think the RUN escaping was ugly I split the shell code into a seperate script to COPY in the old fashioned way.