Updated SC2113 (markdown)

Vidar Holen
2021-07-25 13:17:26 -07:00
parent e9df76b0fb
commit 2fb2726ff1

@@ -2,30 +2,31 @@
### Problematic code:
In `sh`,
```sh
function quit {
exit
#!/bin/sh
function hello {
echo "Hello World"
}
```
### Correct code:
1. add `()` to after the function name. _this code newly cause [[SC2113]]._
```sh
function quit() {
exit
#!/bin/sh
hello() {
echo "Hello World"
}
#=> SC2112: 'function' keyword is non-standard. Delete it.
```
2. remove `function`
### Rationale:
```sh
quit() {
exit
}
#=> No issues detected!
```
`function` is a non-standard keyword that can be used to declare functions in Bash and Ksh.
In POSIX `sh` and `dash`, a function is defined without a `function` keyword. Instead, the function name is followed by `()` as in the correct example.
### Exceptions:
None
### Related resources:
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!