From 3d5a9fadee1f2e7d68f7957cff1c92dd3cb30f91 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Mon, 16 Aug 2021 21:35:15 -0700 Subject: [PATCH] Created SC2297 (markdown) --- SC2297.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 SC2297.md diff --git a/SC2297.md b/SC2297.md new file mode 100644 index 0000000..5c89db7 --- /dev/null +++ b/SC2297.md @@ -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! \ No newline at end of file