mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Add an example of correct code in Bash
12
SC2112.md
12
SC2112.md
@@ -18,6 +18,15 @@ hello() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `function` keyword is a feature of Bash and Ksh, so code that uses it may be intended to be a Bash or Ksh script instead:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#!/bin/bash
|
||||||
|
function hello() {
|
||||||
|
echo "Hello World"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
|
|
||||||
`function` is a non-standard keyword that can be used to declare functions in Bash and Ksh.
|
`function` is a non-standard keyword that can be used to declare functions in Bash and Ksh.
|
||||||
@@ -30,4 +39,5 @@ None.
|
|||||||
|
|
||||||
### Related resources:
|
### Related resources:
|
||||||
|
|
||||||
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
* [Function Definition Command](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05) in the POSIX spec
|
||||||
|
* [Shell Functions](https://www.gnu.org/software/bash/manual/html_node/Shell-Functions.html) in the Bash manual
|
Reference in New Issue
Block a user