mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1080 (markdown)
26
SC1080.md
Normal file
26
SC1080.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
## "You need `\` before line feeds to break lines in `[ ]`.
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
[ "$filename" =
|
||||||
|
"$otherfile" ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
[ "$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!
|
Reference in New Issue
Block a user