Add an example of correct code in Bash

Jordan Christiansen
2025-01-09 15:26:06 -06:00
parent 6269e30936
commit 93e2bc281d

@@ -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