gpt4 book ai didi

linux - bash - 编写函数语法的两种方式

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:53:57 24 4
gpt4 key购买 nike

在 bash 中我们可以写函数,但实际上我们有两种方式(两种语法),

请指教

example1example2 有什么区别

或者也许没有任何区别?

 function I_love_function

{

.
.

}

I_love_function ()

{

.
.
}

如何调用函数I_love_function

最佳答案

发件人:http://www.gnu.org/software/bash/manual/bashref.html#Shell-Functions

Functions are declared using this syntax:

name () compound-command [ redirections ] 
or
function name [()] compound-command [ redirections ]

This defines a shell function named name. The reserved word function is optional. If the function reserved word is supplied, the parentheses are optional.

关于linux - bash - 编写函数语法的两种方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23994072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com