mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2301 (markdown)
29
SC2301.md
Normal file
29
SC2301.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## Parameter expansion starts with unexpected quotes. Double check syntax.
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo ${"Hello World"}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo $"Hello World"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
ShellCheck found a parameter expansion `${...}` that contains an unexpected syntax element, such as single or double quotes.
|
||||||
|
|
||||||
|
In the example, this was due to wrapping a translated string `$".."` with curly braces, which is not valid.
|
||||||
|
|
||||||
|
It is unclear what the intention is with invalid expansions like `${'foo'}`, `${$"foo"}`, so please look up how to do what you were trying to do.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
If this warning triggers for working code, please [submit a bug](https://github.com/koalaman/shellcheck/issues/new).
|
||||||
|
|
||||||
|
### Related resources:
|
||||||
|
|
||||||
|
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user