bash – 为什么我不能在shell中定义一个空函数?
发布时间:2020-12-15 22:51:15 所属栏目:安全 来源:网络整理
导读:我在学习bash.我不小心遇到了空函数的语法错误. #!/bin/bash# script name : empty_function.shfunction empty_func() {}bash empty_function.shempty_function.sh: line 3: syntax error near unexpected token `}'empty_function.sh: line 3: `}' 我想这是
我在学习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: `}' 我想这是因为空函数的定义. 解决方法
bash shell’s grammar根本不允许空功能.函数的语法是:
name () compound-command [redirection] function name [()] compound-command [redirection] 并在以下形式的复合命令中: { list; } 列表不能为空.你可以得到的最接近的是使用null语句或返回: function empty_func() { : } 要么 function empty_func() { return } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- bootstrap datepicker 在bootstrap modal中不显示问题
- angularjs $timeout没有延迟参数的原因
- 解决 vim 插件 taglist 报错:Error detected while proces
- scala – Apache spark mllib.linalg向量与用于机器学习的s
- angularjs – 后退按钮上的Angular UI路由器重载控制器按
- 复制 Windows cmd 窗口命令行的信息方法
- bash – 循环数组,防止通配符扩展(*)
- shell – 检查一行是否以grep 的特定字符串开头
- 【译文&摘抄】Angular、React、Vue的2017
- angularjs – 设置$invalid和$error不会使表单无效
推荐文章
站长推荐
热点阅读