是什么导致此bash语法错误?
发布时间:2020-12-15 21:35:57 所属栏目:安全 来源:网络整理
导读:此命令在命令行上正常工作… if g++ -std=c++11 main.cpp ; then ./a.out; fi 但是当我尝试将它作为函数添加到我的.bashrc时它失败了…… function cgo() { if g++ -std=c++11 "$1" ; then ./a.out; fi }$cgo main.cppbash: syntax error near unexpected to
此命令在命令行上正常工作…
if g++ -std=c++11 main.cpp ; then ./a.out; fi 但是当我尝试将它作为函数添加到我的.bashrc时它失败了…… function cgo() { if g++ -std=c++11 "$1" ; then ./a.out; fi } >$cgo main.cpp bash: syntax error near unexpected token `main.cpp' 我在这做错了什么? 解决方法
使用{braces}时,需要在闭括号之前使用换行符或分号.对于单行,这意味着你需要一个分号
function cgo() { if g++ -std=c++11 "$1" ; then ./a.out; fi; } # ........................................................^ 文档:https://www.gnu.org/software/bash/manual/bashref.html#Command-Grouping (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |