give an explaination behind this shellcheck code.

elreydetoda
2020-04-17 14:17:05 -04:00
parent e9c8925272
commit f12b2c6d30

@@ -1,3 +1,26 @@
# Prefer putting braces around variable references even when not strictly required.
This error is optional and not enabled by default.
## Problematic code:
```shell
partial_path='example'
curl "http://example.com/$partial_path_version/explain.html"
```
## Correct code:
```shell
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:
- [StackOverflow: How do we separate variables from letters in shell scripting](https://stackoverflow.com/questions/18320133/how-do-we-separate-variables-from-letters-in-shell-scripting)