koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.45k stars 1.78k forks source link

SC2282 - variables starting with numbers aren't flagged as errors if done in arithmetic context #2958

Open RVC2020 opened 7 months ago

RVC2020 commented 7 months ago

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:


#!/bin/bash
((1num=1+2))
2num=$((10+1))

Here's what shellcheck currently says:

In test.sh line 3: 2num=$((10+1)) ^------------^ SC2282 (error): Variable names can't start with numbers, so this is interpreted as a command.

Here's what I wanted or expected to see:

1num also be flagged as an error under SC2282,