From 9bb672cff2b7cb8216fe67f46bbc3959ce47f2bf Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 21 Oct 2018 17:34:14 -0700 Subject: [PATCH] Created SC1133 (markdown) --- SC1133.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 SC1133.md diff --git a/SC1133.md b/SC1133.md new file mode 100644 index 0000000..bd2496d --- /dev/null +++ b/SC1133.md @@ -0,0 +1,32 @@ +## Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one. + +### Problematic code: + +```sh +dmesg + | grep "error" +``` + +### Correct code: + +```sh +dmesg | + grep "error" +``` + +### Rationale: + +ShellCheck has found a line that unexpectedly started with `|`, `||` or `&&`. This usually happens when a line is broken incorrectly. + +When breaking around a `|`, `||` or `&&`, there are two options: + +* Break the line *after* this token. `dmesg` is a complete command by itself, but `dmesg |` is not so the shell knows to continue on the next line. +* Use a `\` at the end of the previous line to explicitly tell the shell to continue on the next. + +### Exceptions: + +None. This is a syntax error. + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file