mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2113 (markdown)
21
SC2113.md
21
SC2113.md
@@ -1,4 +1,8 @@
|
||||
Instead of
|
||||
## `function` keyword is non-standard. Use `foo()` instead of `function foo`.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
In `sh`,
|
||||
|
||||
```sh
|
||||
function quit {
|
||||
@@ -6,11 +10,22 @@ function quit {
|
||||
}
|
||||
```
|
||||
|
||||
...add the parenthesis to the function name and remove the word "function":
|
||||
### Correct code:
|
||||
|
||||
1. add `()` to after the function name. _this code newly cause [[SC2113]]._
|
||||
|
||||
```sh
|
||||
function quit() {
|
||||
exit
|
||||
}
|
||||
#=> SC2112: 'function' keyword is non-standard. Delete it.
|
||||
```
|
||||
|
||||
2. remove `function`
|
||||
|
||||
```sh
|
||||
quit() {
|
||||
exit
|
||||
}
|
||||
#=> No issues detected!
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user