From a691762effcf1f86304a14c9f8c12d916602a4a6 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Mon, 21 May 2018 17:09:16 -0700 Subject: [PATCH] Created SC1036 (markdown) --- SC1036.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 SC1036.md diff --git a/SC1036.md b/SC1036.md new file mode 100644 index 0000000..e63a73d --- /dev/null +++ b/SC1036.md @@ -0,0 +1,35 @@ +## `(` is invalid here. Did you forget to escape it? + +### Problematic code: + +```sh +echo (foo) bar +``` + +### Correct code: + +Depends on your intention: + +```sh +echo "(foo) bar" # Literal parentheses +echo "$(foo) bar" # Command expansion +echo "foo bar" # Tried to use parentheses for grouping or function invocation +``` + +### Rationale: + +ShellCheck expected an ordinary shell word but found an opening parenthesis instead. + +Determine what you intended the parenthesis to do and rewrite accordingly. Common issues include: + +* Wanting them to be literal, as in `echo (FAIL) Some tests failed`. In this case, it requires quoting. +* Wanting command expansion, as in `echo Today is (date)`. Add the missing `$`: `echo "Today is $(date)"` +* Adding parentheses because other languages need them in that context, such as `foo (bar, 42)` to call a function. This should be `foo bar 42`. Also, shells do not support tuples or passing arrays as single parameters. + +### Exceptions: + +None + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file