Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaped dollar signs in heredoc blocks are not recognized correctly. #1011

Open
1 of 3 tasks
lucassus opened this issue Apr 10, 2024 · 0 comments
Open
1 of 3 tasks

Escaped dollar signs in heredoc blocks are not recognized correctly. #1011

lucassus opened this issue Apr 10, 2024 · 0 comments

Comments

@lucassus
Copy link

lucassus commented Apr 10, 2024

  • This is a bug report
  • This is a feature request
  • I searched existing issues before opening this one

I have the following RUN with heredoc in my Dockerfile

ARG WKHTMLTOPDF_VERSION="0.12.6.1-3"

# Install patched wkhtmltopdf for PDF generation, see https://github.com/wkhtmltopdf/packaging/releases
RUN <<EOF bash
  set -eux

  # We need to escape dollar sign in variables to prevent it from being expanded during the build.
  # For instance use \${version_codename}.
  version_codename=$(grep --only-matching --perl-regexp '(?<=VERSION_CODENAME=).+$' /etc/os-release)
  download_url="https://github.com/wkhtmltopdf/packaging/releases/download/${WKHTMLTOPDF_VERSION}/wkhtmltox_${WKHTMLTOPDF_VERSION}.\${version_codename}_${BUILDARCH}.deb"

  curl \${download_url} --location --output /tmp/wkhtmltopdf.deb
  apt-get install --yes --no-install-recommends /tmp/wkhtmltopdf.deb
  rm /tmp/wkhtmltopdf.deb
EOF

It works fine. But the linter complains with:

-:48 SC1083 warning: This } is literal. Check expression (missing ;/\n?) or quote it.

When I quote download_url variable, like:

curl "\${download_url}" --location --output /tmp/wkhtmltopdf.deb

I have another warning:

-:48 SC2034 warning: download_url appears unused. Verify use (or export if used externally).

Expected behavior

The linter should understand that I have to escape a dollar sign in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant