koalaman/shellcheck

False positive SC2034: Variable incorrectly marked as unused inside indented here-document

Closed this issue · 1 comments

For bugs

  • Rule Id (if any, e.g. SC1000): SC2034
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/bash

function main() {
    local FOO=bar

    sed 's/^    EOF//' <<- '    EOF'
    I am now using the variable: ${FOO}
    EOF
}

Here's what shellcheck currently says:

Line 4	SC2034: FOO appears unused. Verify use (or export if used externally).

Here's what I wanted or expected to see:

Nothing.

Nevermind, the variable is actually not evaluated at all.
Shellcheck is actually correct.
Closing, sorry.