Created SC2297 (markdown)

Vidar Holen
2021-08-16 21:35:15 -07:00
parent bc07c19622
commit 3d5a9fadee

29
SC2297.md Normal file

@@ -0,0 +1,29 @@
## Double quotes must be outside ${}: ${"invalid"} vs "${valid}".
### Problematic code:
```sh
echo ${"USER"}
```
### Correct code:
```sh
echo "${USER}"
```
### Rationale:
ShellCheck found a parameter expansion containing what appears to be a quoted variable name.
While the parameter expansion itself must be quoted, as in `"${valid}"`, the quotes may not appear inside the `{}` as in `${"invalid"}`.
Also note that translated strings like `$"Hello"` may not use curly braces.
### Exceptions:
None
### Related resources:
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!