SC2004 false positive on assignment to array position
partcyborg opened this issue · comments
For bugs
- Rule Id (if any, e.g. SC1000):
- My shellcheck version (
shellcheck --version
or "online"): 0.10.0, plus online - The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
NOTE: this is the simplest test case I could think of. Real world use case is more involved.
#!/bin/bash
declare -a foo=()
i=0
foo[$i]=bar
echo "${foo[@]}"
Here's what shellcheck currently says:
foo[$i]=bar
^-- SC2004 (style): $/${} is unnecessary on arithmetic variables.
Here's what I wanted or expected to see:
The checks should pass, as there is no arithmetic involved, nor is there a code syntax issue.
Nevermind, I did not realize $ wasn't necessary in arrays