Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 3 revisions

Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one.

Problematic code:

dmesg
  | grep "error"

Correct code:

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:

In v0.7.2 and below, this warning triggered incorrectly when starting a line with &>. In these versions, you can either ignore the warning, or move the redirection after the command name.

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally