org.sonar.l10n.shellcheck.rules.shellcheck.SC2168.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-shellcheck-plugin Show documentation
Show all versions of sonar-shellcheck-plugin Show documentation
ShellCheck plugin for SonarQube
'local' is only valid in functions.
Problematic code
local foo=bar
echo "$foo"
Correct code
foo=bar
echo "$foo"
Rationale
In Bash, local
can only be used in functions. In other contexts, it's an error.
Exceptions
It's possible to source files containing local
from a function context but not from any other context. This is not good practice, but in these cases you can [[ignore]] this error.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy