Closed kurahaupo closed 2 years ago
ok, i have no idea what that () is for so then i will change that to
function main {
The "original" way to declare a function was with empty parentheses; this was established circa 1978:
funcname () {
body
commands
here
}
The function
keyword was a latter addition, circa 1987:
function funcname {
body
commands
here
}
There are pro's and con's both ways.
As an extension, Bash allows any compound statement as the body, not just a brace group, so you can write:
check_thing ()
if (( want_thing ))
then make thing
else rm thing
fi
without curly brackets, or
do_stuff_in_subshell() (
these commands run in a subshell
)
without curly brackets.
The following syntax is an unportable extension:
Use either
function
or()
, not both.