diff --git a/Sc2004.md b/Sc2004.md new file mode 100644 index 0000000..22f8411 --- /dev/null +++ b/Sc2004.md @@ -0,0 +1,15 @@ +# Don't use $ on variables in (( )). + +### Problematic code: + + echo $(($n+1)) + +### Correct code: + + echo $((n+1)) + +### Rationale: + +The `$` on regular variables in arithmetic contexts has no purpose, and is just noise. + +The `$` does matter for special variables like `$1` vs `1`, `$#` vs `#`, and ShellCheck does not produce this style suggestion for these cases. \ No newline at end of file