mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1095 (markdown)
33
SC1095.md
Normal file
33
SC1095.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
## You need a space or linefeed between the function name and body.
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function foo{
|
||||||
|
echo "hello world"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
Prefer POSIX syntax:
|
||||||
|
```sh
|
||||||
|
foo() {
|
||||||
|
echo "hello world"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, add the missing space between function name and opening `{`:
|
||||||
|
```sh
|
||||||
|
# v-- Here
|
||||||
|
function foo {
|
||||||
|
echo "hello world"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
When using `function` keyword function definitions without `()`, a space is required between the function name and the opening `{`.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None.
|
Reference in New Issue
Block a user