From 6a0374adb09ffd14992e12ba26b9bb3cfa36c809 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 22 Nov 2014 09:01:16 -0800 Subject: [PATCH] Created SC1037 (markdown) --- SC1037.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 SC1037.md diff --git a/SC1037.md b/SC1037.md new file mode 100644 index 0000000..41139e1 --- /dev/null +++ b/SC1037.md @@ -0,0 +1,21 @@ +## Without braces, this is $1 plus a literal. Use ${10} instead. + +### Problematic code: + + echo "Ninth parameter: $9" + echo "Tenth parameter: $10" + +### Correct code: + + echo "Ninth parameter: $9" + echo "Tenth parameter: ${10}" + +### Rationale: + +For legacy reasons, `$10` is interpreted as the variable `$1` followed by the literal string `0`. + +Curly braces are needed to tell the shell that both digits are part of the parameter expansion. + +### Contraindications + +If you wanted the trailing digits to be literal, `${1}0` will make this clear to both humans and shellcheck. \ No newline at end of file