From 0ec88489928b0fd9958f09a957cc5470a4ce1141 Mon Sep 17 00:00:00 2001 From: koalaman Date: Thu, 14 Nov 2013 11:34:48 -0800 Subject: [PATCH] Created Sc2004 (markdown) --- Sc2004.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Sc2004.md 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