Both
Code:
function hw1()
{
echo "hello world"
}
and
Code:
function hw2
{
echo "hello world"
}
work. So why do most Bash functions have the () as in the first code?
Bumbling on ...
Code:
hw3
{
echo "hello world"
}
^^^ doesn't work; system thinks hw3 maybe a command but
Code:
hw3()
{
echo "hello world"
}
and
Code:
function hw3
{
echo "hello world"
}
both work so I get the impression that either Function or () are sufficient to prevent the function from being confused with a command.
But I see examples with both function and ()? So is it just good coding practice or are there technical reasons for having both function and ()?
Bookmarks