Skip to content
Joachim Ansorg edited this page Oct 31, 2022 · 2 revisions

You need \ before line feeds to break lines in [ ].

Problematic code:

[ "$filename" =
  "$otherfile" ]

Correct code:

[ "$filename" = \
  "$otherfile" ]

Rationale:

Bash/ksh [[ ]]] can include line breaks anywhere, but [ ] requires that you escape them. If you are writing a multi-line [ .. ] statement, make sure to include these escapes. If the [ ] is supposed to be on a single line, make sure the ] is there.

Exceptions:

None

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