From d933963a3cda543e4aa1b57f4c709d62b0004362 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 6 Dec 2020 21:08:14 -0800 Subject: [PATCH] Created SC1140 (markdown) --- SC1140.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 SC1140.md diff --git a/SC1140.md b/SC1140.md new file mode 100644 index 0000000..c51c33c --- /dev/null +++ b/SC1140.md @@ -0,0 +1,26 @@ +## Unexpected parameters after condition. Missing &&/||, or bad expression? + +### Problematic code: + +```sh +[ "$1" ] input="$1" +``` + +### Correct code: + +```sh +[ "$1" ] && input="$1" +``` +### Rationale: + +ShellCheck found characters (other than redirections) after the `]` or `]]` in a test expression. This is not valid. + +This sometimes happens when there was an additional expression or command, but joining `||` or `&&` is missing. Alternatively, it could happen due to typos (like `[[ $1 ]]]` with an extra `]`), or generally from malformed test expressions. + +### Exceptions: + +None + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file