-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2154
koalaman edited this page Mar 1, 2015
·
15 revisions
var=name
n=42
echo "$var_$n.jpg"
var=name
n=42
echo "${var}_$n.jpg"
ShellCheck has noticed that you reference a variable that is not assigned. Double check that the variable is indeed assigned, and that the name is not misspelled.
Note: This message only triggers for variables with lowercase characters in their name (foo
and kFOO
but not FOO
) due to the standard convention of using lowercase variable names for unexported, local variables.
ShellCheck does not attempt to figure out runtime or dynamic assignments like with source mycommonvars.sh
or eval var=value
.
If you know for a fact that the variable is set, you can use ${var:?}
to fail if the variable is unset (or empty). You can also disable the message with a directive.