Created Sc2004 (markdown)

koalaman
2013-11-14 11:34:48 -08:00
parent a8c6bdc742
commit 0ec8848992

15
Sc2004.md Normal file

@@ -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.