Sensitive bourne shells Medium

Bourne shells are highly sensitive to whitespace, and adding or removing spaces can drastically alter the meaning of a script. Tool has detected a missing space at the indicated position, which could lead to unexpected behavior.

Detector ID
shell/sensitive-bourne-shells@v1.0
Category
Common Weakness Enumeration (CWE) external icon
-
Tags
-

Noncompliant example

1
2# Noncompliant: Missing space before `]]` in conditional expression.
3while [[ "$COUNT" -lt 10]]; do
4  echo "$COUNT"
5  ((COUNT++))
6done

Compliant example

1
2# Compliant: Correct spacing allows proper parsing of the conditional expression.
3while [[ "$COUNT" -lt 10 ]]; do
4  echo "$COUNT"
5  ((COUNT++))
6done