You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some further experiments showed that also other non-variable parameters are interpreted as variable names. This includes (but is not necessarily limited to) read -d a, read -i a and read -u a – in each of these cases shellcheck interprets a as a variable name even though it is a delimiter, initial text, or file descriptor.
Note that a has to be a valid variable identifier for shellcheck to give the false positive SC2034 (appears unused) and the false negative, that is, missing warning SC2154 (referenced but not assigned).
I am getting a similar error on the following (with shellcheck 0.4.6, so may already addressed in newer versions, passes fine in v0.7.1+git109.c9be7ab)
whileread -a files -r
doif! downloadFile "${files[0]}""${files[1]}";then((++downloadFailures))echo"downloadFailures ${downloadFailures}"fidone<"./filelist.txt"
Bug Template
Bug (false negative)
shellcheck --version
says 0.6.0, my package managerpacman -Qi
says 0.6.0-120For new checks
Here's a snippet or screenshot that shows the problem:
The following script will print the literal string
a
and read input to the default variableREPLY
. Afterwards the unassigned variable$a
is accessed.Here's what shellcheck currently says:
There is no output. Shellcheck doesn't find a problem even though there is one (false negative).
Here's what I wanted or expected to see:
More Information
Shellcheck seems to misinterpret the prompt argument given to
read
's-p
option as a variable name. I did some further experiments:For the script
shellcheck prints a warning even though there is no problem (false positive).
I expected shellcheck to remain silent.
For the script
shellcheck remains silent even though there is a problem (false negative). I expected the output
The text was updated successfully, but these errors were encountered: