Skip to content
elreydetoda edited this page Apr 17, 2020 · 4 revisions

Prefer putting braces around variable references even when not strictly required.

This error is optional and not enabled by default.

Problematic code:

partial_path='example'

curl "http://example.com/$partial_path_version/explain.html"

Correct code:

partial_path='example'

curl "http://example.com/${partial_path}_version/explain.html"

Rationale:

If a variable gets called, and there is a string that gets appended to the variable that could get misinterpreted as possibly part of the name of the variable. Then it will not call the right variable.

Related resources:

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally