koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.2k stars 1.77k forks source link

Local variable escaped from the function #3044

Open A4-Tacks opened 1 month ago

A4-Tacks commented 1 month ago

For bugs

For new checks and feature suggestions

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

#!/bin/bash
f() {
    local x=
}
echo "$x"

Here's what shellcheck currently says:

Here's what I wanted or expected to see:


In - line 5:
echo "$x"
      ^-- SC2154 (warning): x is referenced but not assigned.

For more information:
  https://www.shellcheck.net/wiki/SC2154 -- x is referenced but not assigned.