mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2113 (markdown)
25
SC2113.md
25
SC2113.md
@@ -1,16 +1,31 @@
|
|||||||
Instead of
|
## `function` keyword is non-standard. Use `foo()` instead of `function foo`.
|
||||||
|
|
||||||
``` sh
|
### Problematic code:
|
||||||
|
|
||||||
|
In `sh`,
|
||||||
|
|
||||||
|
```sh
|
||||||
function quit {
|
function quit {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
...add the parenthesis to the function name and remove the word "function":
|
### Correct code:
|
||||||
|
|
||||||
``` sh
|
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() {
|
quit() {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
#=> No issues detected!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user