buildah icon indicating copy to clipboard operation
buildah copied to clipboard

HEREDOC: Escaping `$` seems off

Open LecrisUT opened this issue 2 years ago • 4 comments

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

LecrisUT avatar Mar 20 '24 13:03 LecrisUT

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Apr 20 '24 00:04 github-actions[bot]

Maybe #5473

LecrisUT avatar Apr 20 '24 02:04 LecrisUT

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar May 22 '24 00:05 github-actions[bot]

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.

phlogistonjohn avatar Aug 27 '24 19:08 phlogistonjohn