Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC2178 indefinitely triggers SC2128 when it should not, i.e., after overriding an array variable with a single string #1630

Open
evandrocoan opened this issue Jun 30, 2019 · 0 comments

Comments

@evandrocoan
Copy link

evandrocoan commented Jun 30, 2019

Line 449:
stringarray="${stringarray[1]:10}";
^-- SC2178: Variable was used as an array but is now assigned a string.

Line 450:
if [[ "${stringarray}" != *'^{}' ]];
   ^-- SC2128: Expanding an array without an index only gives the first element.

This was not a mistake, I purposefully overwrote the array with a single string.

The problem is that, after doing that, shellcheck still keeps thinking the stringarray variable is an array, but it is a string and I am correctly accessing it.

Related:

  1. SC2178/SC2128 false positives on local variables #680
  2. Enhance SC2178/SC2128 errors when the variable is an internal shell array variable #1101
  3. inconsistent flagging of SC2178/SC2128 based on local usage #1309
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant