shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC2086: Numeric expansion

Open aeiplatform opened this issue 2 years ago • 1 comments

For bugs

  • Rule Id: SC2086
  • My shellcheck version: 0.9.0
  • [x] The rule's wiki page does not already cover this at Wiki
  • [x] 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/sh
a=hey
b=${#a}
echo $b ${#a}

Here's what shellcheck currently says:

Line 4:
echo $b ${#a}
     ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Here's what I wanted or expected to see:

Nothing. Expansion is always numeric length.

aeiplatform avatar May 23 '23 15:05 aeiplatform

This rule should behave same like int constant assignment.

b=3
b=${#a}

aeiplatform avatar Sep 25 '23 10:09 aeiplatform