简体   繁体   English

使用 Cmder 作为 bash 控制台,其中声明 function 以调用 arguments,如别名

[英]With Cmder as a bash console where to declare a function to call with arguments, like an alias

I use Cmder, I declared bash aliases in Cmder\config\user_profile.sh and I can use them in bash console mode.我使用 Cmder,我在Cmder\config\user_profile.sh中声明了 bash 别名,我可以在 bash 控制台模式下使用它们。 But in the same file declared functions don't work in bash console mode.但是在同一个文件中声明的函数在 bash 控制台模式下不起作用。

function hello {
    echo "Hello $1 !"
}

Wrong file, wrong syntax, not possible???错误的文件,错误的语法,不可能???

Ok, I found the pb: We need to respect the syntax like this :好的,我找到了 pb: 我们需要尊重这样的语法:

function hello {
    echo "Hello $1 !"
}

and never like this:从来没有这样:

function hello { echo "Hello $1 !" }

because of a problem of unexpected end file.由于意外结束文件的问题。 Indeed we are not under Windows shell: o:)事实上,我们不在 Windows shell 之下:o:)

UPDATE: functional syntax on one line更新:一行的功能语法

hello() { echo "Hello $1 !"; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM