diff --git a/SC2250.md b/SC2250.md index 8ffecec..fdf0ac2 100644 --- a/SC2250.md +++ b/SC2250.md @@ -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) \ No newline at end of file