在tcsh中声明函数时放错了() [英] Badly placed ()'s while declaring a function in tcsh

查看:80
本文介绍了在tcsh中声明函数时放错了()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在tcsh中声明一个函数并调用它.

I'm trying to declare a function in tcsh and to call it.

#! /bin/tcsh -f

helloWorld () {
    echo "a"
}

helloWorld

我遇到以下错误:

< 512 mews2895 ~/tmp/script> 1.sh
Badly placed ()'s.

这里有人可能是什么问题吗?

Does anyone here what the problem might be?

谢谢

推荐答案

tcsh不支持函数.

tcsh does not support functions.

最佳解决方案:使用具有此功能的外壳,例如bash.

Best solution: Use a shell that does, such as bash.

如果由于某种原因必须使用tcsh,别名将解决您的直接问题,但比函数弱得多.

If you must use tcsh for some reason, aliases will solve your immediate problem, but are much weaker than functions.

alias helloWorld 'echo "a"'

另一种可能的解决方案是调用一个单独的脚本.(您必须确保所调用的脚本在您的 $ PATH 中.)

Another possible solution is to invoke a separate script. (You'll have to ensure that the invoked script is in your $PATH.)

这篇关于在tcsh中声明函数时放错了()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆