Skip to content

Latest commit

 

History

History
31 lines (19 loc) · 1.04 KB

SC2153.md

File metadata and controls

31 lines (19 loc) · 1.04 KB

Pattern: Possible variable misspelling

Issue: -

Description

You reference a variable that is not assigned in the script, which has a name remarkably similar to one that is explicitly assigned. You should verify that the variable name is spelled correctly.

Note: This error only triggers for environment variables (all uppercase variables), and only when they have names similar to something assigned in the script. If the variable is script-local, it should by convention have a lowercase name.

Example of incorrect code:

MY_VARIABLE="hello world"
echo "$SOMEVARIABLE"

Example of correct code:

MY_VARIABLE="hello world"
echo "$MY_VARIABLE"

Exceptions

If you've double checked and ensured that you did not intend to reference the specified variable, you can disable this message with a directive. The message will also not appear for guarded references like ${ENVVAR:-default} or ${ENVVAR:?Unset error message here}.

Further Reading