mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1133 (markdown)
32
SC1133.md
Normal file
32
SC1133.md
Normal file
@@ -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!
|
Reference in New Issue
Block a user