Braces required for positionals Medium

For legacy reasons, some variables are seen as one variable followed by a literal string. Curly braces are necessary to indicate that both characters are part of the parameter expansion, ensuring the shell interprets them correctly.

Detector ID
shell/braces-required-for-positionals@v1.0
Category
Common Weakness Enumeration (CWE) external icon
-
Tags
-

Noncompliant example

1
2# Noncompliant: Uses `$11`, which will be interpreted as `$1` followed by 1 or 0.
3echo "The 11th argument is $11"

Compliant example

1
2# Compliant: Uses `${11}` which is properly referencing the 11th argument.
3echo "The 11th argument is ${11}"