function keyword is non-standard. Delete it.
SC2112 – ShellCheck Wiki
See this page on GitHubfunction keyword is non-standard. Delete it.
Problematic code:
#!/bin/sh
function hello() {
echo "Hello World"
}
Correct code:
#!/bin/sh
hello() {
echo "Hello World"
}
Rationale:
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 instead declared without the function keyword as in the correct example.
Exceptions:
None.
Related resources:
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
浙公网安备 33010602011771号