【发布时间】:2013-01-21 15:02:52
【问题描述】:
我正在编写一个 csh 别名,以便可以在我的 csh 中使用以下 bash 函数:
function up( )
{
LIMIT=$1
P=$PWD
for ((i=1; i <= LIMIT; i++))
do
P=$P/..
done
cd $P
export MPWD=$P
}
(我从here偷了上面的bash函数)
我写了这个:
alias up 'set LIMIT=$1; set P=$PWD; set counter = LIMIT; while[counter!=0] set counter = counter-1; P=$P/.. ; end cd $P; setenv MPWD=$P'
但是,我收到以下错误:
while[counter!=0]: No match.
P=/net/devstorage/home/rghosh/..: Command not found.
end: Too many arguments.
我的脚本没有按预期工作。我一直在阅读来自 here 的 csh。
我不是 csh 专家,我上面写的是我的第一个 csh 脚本。请让我知道我做错了什么。
【问题讨论】:
-
csh使用setenv而不是export。 -
@WilliamPursell 我将导出更改为 setenv,但我仍然遇到同样的错误
-
@WilliamPursell 现在的问题有很大不同。你能再看看它吗?
-
在我看来,正确的解决方案是:“不要使用 csh”!
-
算术需要'at-signment' ("@");除此之外,我同意威廉普尔塞尔的观点。或者,如果你真的想使用 write csh 别名,你最好非常非常仔细地阅读它的文档。