Open
Description
For bugs
- Rule Id: SC2004
- My shellcheck version: online
- 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:
#!/usr/bin/env bash
char="-"
value=10
readonly -A CHAR_VALUES=(["+"]=1 ["-"]=2 ["|"]=3)
(( value += CHAR_VALUES[$char] ))
Here's what shellcheck currently says:
[Line 7:](javascript:setPosition(7, 25))
(( value += CHAR_VALUES[$char] ))
^-- [SC2004](https://www.shellcheck.net/wiki/SC2004) (style): $/${} is unnecessary on arithmetic variables.
Here's what I wanted or expected to see:
Nothing, as removing the $
changes the meaning of the expression.
Note: If $char
is changed to "$char"
, shellcheck no longer complains.
Metadata
Metadata
Assignees
Labels
No labels