Linux 位置不好()';在tcsh中声明函数时
我试图在tcsh中声明一个函数并调用它Linux 位置不好()';在tcsh中声明函数时,linux,shell,Linux,Shell,我试图在tcsh中声明一个函数并调用它 #! /bin/tcsh -f helloWorld () { echo "a" } helloWorld 我得到以下错误: < 512 mews2895 ~/tmp/script> 1.sh Badly placed ()'s. 1.sh 位置不好。 这里有人知道问题出在哪里吗 谢谢请在下面的代码中尝试使用tcsh #! /bin/tcsh -f goto helloWorld helloWorld: echo "a" t
#! /bin/tcsh -f
helloWorld () {
echo "a"
}
helloWorld
我得到以下错误:
< 512 mews2895 ~/tmp/script> 1.sh
Badly placed ()'s.
<512 mews2895~/tmp/script>1.sh
位置不好。
这里有人知道问题出在哪里吗
谢谢请在下面的代码中尝试使用
tcsh
#! /bin/tcsh -f
goto helloWorld
helloWorld:
echo "a"
tcsh不支持功能
alias helloWorld 'echo "a"'
最佳解决方案:使用一个shell,比如bash
如果出于某种原因必须使用tcsh,别名可以解决眼前的问题,但比函数弱得多
alias helloWorld 'echo "a"'
另一种可能的解决方案是调用单独的脚本。(您必须确保调用的脚本位于
$PATH
中)tcsh中没有函数。因此,我看到了两种选择:
- 使用别名:
- 使用转到。(人们倾向于批评,但这实际上取决于上下文)
巴勃罗/bin/tcsh-f后面不应该有空格代码>。此外,tcsh没有功能:Ho。。谢谢,我不知道。。Thanks@fedorqui:实际上空格是可选的。@KeithThompson哦,很有趣,很高兴知道。谢谢你的信息!这不是一个函数。没错,不是一个函数,但如上所述,这是一个合理的代理。看起来没有好的选择:(为什么“使用不同的shell”不是有效的响应?它确实解决了问题。