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
Here's a snippet or screenshot that shows the problem:
#!/bin/bash# SC2269 not triggered for indexed arrays
array=(1 2 3 4)
foriin"${!array[@]}";do
array[i]="${array[i]}"done
or likewise:
#!/bin/bash# SC2269 not triggered for associative arraysdeclare -A array
array[foo]=1
array[bar]=2
array[baz]=3
forkin"${!array[@]}";do
array[k]="${array[k]}"done
Contrast this with
#!/bin/bash# SC2269 triggered for simple variable assignments
foo=1
foo="${foo}"
^-- [SC2269](https://www.shellcheck.net/wiki/SC2269) (info): This variable is assigned to itself, so the assignment does nothing.
(as output for the third example with normal variable assignments)
Reason: Assigning array elements to themselves doesn't change their value, just as assigning variables to themselves doesn't change them. Still, for arrays, this may be more involved to check due to the iteration (and not even counting the possible indirect references that ShellCheck cannot see, as in SC2302).
For bugs
shellcheck --version
or 'online'): onlineFor new checks and feature suggestions
Here's a snippet or screenshot that shows the problem:
or likewise:
Contrast this with
Here's what shellcheck (https://www.shellcheck.net/) currently says:
(both for indexed and associative arrays)
Here's what I wanted or expected to see:
(as output for the third example with normal variable assignments)
Reason: Assigning array elements to themselves doesn't change their value, just as assigning variables to themselves doesn't change them. Still, for arrays, this may be more involved to check due to the iteration (and not even counting the possible indirect references that ShellCheck cannot see, as in SC2302).
As far as I see, the respective check is done in:
shellcheck/src/ShellCheck/Analytics.hs
Lines 4259 to 4277 in d3001f3
Might it be possible to extend the checks to array elements, for shells supporting them?
The text was updated successfully, but these errors were encountered: