Unescaped Variable Low

The script attempts to concatenate a variable within a quoted string but mistakenly includes unescaped quotes, leading to syntax errors and improper string formation. To fix, remove or escape the unnecessary quotes.

Detector ID
shell/unescaped-variable@v1.0
Category
Common Weakness Enumeration (CWE) external icon
-
Tags
-

Noncompliant example

1
2# Noncompliant: Surrounding quotes unintentionally unquote the variable expansion.
3message="Welcome to "$USER"'s home directory"
4echo $message

Compliant example

1
2# Compliant: Variable expansion properly included within the quoted string.
3message="Welcome to $USER's home directory"
4echo "$message"