Skip to content

Files

Latest commit

 

History

History
35 lines (21 loc) · 1007 Bytes

SC1141.md

File metadata and controls

35 lines (21 loc) · 1007 Bytes

Pattern: Unexpected token after compound command

Issue: -

Description

ShellCheck found unexpected trailing characters after a compound command.

The only things allowed after compound commands are redirections, shell keywords, and the various command separators (;, &, |, &&, ||).

In the first example, a | was missing, causing head to appear as an unexpected trailing word, instead of being piped to. In the second example, a lack of quoting caused file to appear as an unexpected trailing word, instead of being part of the redirection.

Examine your statement and correct the problem.

Example of incorrect code:

while echo "$2"; do true; done \
  head -n "$1"

while sleep 1; do date; done > my file

Example of correct code:

while echo "$2"; do true; done \
  | head -n "$1"

while sleep 1; do date; done > "my file"

Further Reading