function foo() {}
我进行搜索查询info bash并查看POSIX的相关章节中的函数关键字,但没有找到.
什么是function一些bash脚本中使用的关键字?这是一些不赞成的语法吗?
我在学习bash.我不小心遇到了空函数的语法错误.
#!/bin/bash
# script name : empty_function.sh
function empty_func() {
}
bash empty_function.sh
empty_function.sh: line 3: syntax error near unexpected token `}'
empty_function.sh: line 3: `}'
Run Code Online (Sandbox Code Playgroud)
我想这是因为空函数的定义.我想知道为什么我不能定义一个空函数?