From 0ca982cb1ad0a06fcbacb5c732ec78416c635f86 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Wed, 20 Mar 2019 22:09:17 -0700 Subject: [PATCH] Created SC2247 (markdown) --- SC2247.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 SC2247.md diff --git a/SC2247.md b/SC2247.md new file mode 100644 index 0000000..3df3af5 --- /dev/null +++ b/SC2247.md @@ -0,0 +1,30 @@ +## Flip leading $ and " if this should be a quoted substitution. + +### Problematic code: + +```sh +var=$"(whoami)" +``` + +### Correct code: + +```sh +var="$(whoami)" +``` + +### Rationale: + +ShellCheck has found a `$"(` or `$"{` . This is most likely due to flipping the dollar-sign and double quote: + + echo $"(cmd)" # Supposed to be "$(cmd)" + echo $"{var}" # Supposed to be "${var}" + +Instead of quoted substitutions, these will be interpreted as localized string resources (`$".."`) containing literal parentheses or curly braces. If this was not intentional, you should flip the `"` and `$` like in the example. + +### Exceptions: + +If you intentionally wanted a localized string literal `$".."` that starts with `(` or `{`, either [[ignore]] this error or start it with a different character. + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file