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
I tried on shellcheck.net and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#!/bin/bash
a=(a b c)
echo${!a[@]}
Here's what shellcheck currently says:
Line 3:
echo ${!a[@]}
^-- SC2068: Double quote array expansions to avoid re-splitting elements.
Here's what I wanted or expected to see:
${!a[@]} (with the exclamation mark) expands to array indices, so for normal arrays there's no danger of re-splitting. However, if the array is an associative array, then the indices can contain whitespace and the warning is good.
Improving this depends on how deeply shellcheck understands the code:
if it knows it's dealing with a usual non-associative array, it could omit the warning, and keep emitting it for associative arrays
if it doesn't know the above, the check can be left as is and the limitation should be documented in the Wiki
(Haven't checked if it's already there, but a unit test would be good to have to ensure desired behavior even if it's the current one.)
The text was updated successfully, but these errors were encountered:
scop
added a commit
to scop/bash-completion
that referenced
this issue
Jan 4, 2020
For bugs
shellcheck --version
or "online"): onlineHere's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
${!a[@]}
(with the exclamation mark) expands to array indices, so for normal arrays there's no danger of re-splitting. However, if the array is an associative array, then the indices can contain whitespace and the warning is good.Improving this depends on how deeply shellcheck understands the code:
(Haven't checked if it's already there, but a unit test would be good to have to ensure desired behavior even if it's the current one.)
The text was updated successfully, but these errors were encountered: