diff --git a/SC2004.md b/SC2004.md index 1ebfe7c..c5a7941 100644 --- a/SC2004.md +++ b/SC2004.md @@ -3,18 +3,18 @@ ### Problematic code: ```sh -echo $(($n+1)) +echo $(($n + ${arr[i]})) ``` ### Correct code: ```sh -echo $((n+1)) +echo $((n + arr[i])) ``` ### Rationale: -The `$` on regular variables in arithmetic contexts is unnecessary, and can even lead to subtle bugs. This is because the contents of `$((..))` is first expanded into a string, and then evaluated as an expression: +The `$` or `${..}` on regular variables in arithmetic contexts is unnecessary, and can even lead to subtle bugs. This is because the contents of `$((..))` is first expanded into a string, and then evaluated as an expression: ```sh $ a='1+1'