Created SC1037 (markdown)

koalaman
2014-11-22 09:01:16 -08:00
parent f3326a503b
commit 6a0374adb0

21
SC1037.md Normal file

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