What are the parentheses used for in a bash shell script function definition like “f () {}”? Is it different than using the “function” keyword?

后端 未结 3 915
灰色年华
灰色年华 2020-12-28 12:21

I\'v always wondered what they\'re used for? Seems silly to put them in every time if you can never put anything inside them.

function_name () {
    #stateme         


        
3条回答
  •  囚心锁ツ
    2020-12-28 12:51

    The empty parentheses are required in your first example so that bash knows it's a function definition (otherwise it looks like an ordinary command). In the second example, the () is optional because you've used function.

提交回复
热议问题