在.cshrc中设置PATH无效



在我的.cshrc中有两行:

setenv PATH /a/bin:$PATH
cd /a/

的结果
setenv

...
PATH=/a/bin:<original PATH>
...

的结果
ls -l /a/bin

-rwxr-x--x 1 evgeny evgeny 122 May 13 13:43 run_me

的结果
run_me 

run_me: Command not found.

如何修复?

因为tcshcsh使用与bash不同的语法。您确定您使用的是类ssh shell吗?对于类似sh的shell(例如bash),您需要将命令添加到.profile中。

尝试下一个进入你的.cshrc:

set path=(/a/bin $path)

和relog,或者使用

source .cshrc #for re-read the cshrc
rehash #reread avialable commands in the path

EDIT - test result

[me@orion]/home/me(135)> echo $0
-tcsh
[me@orion]/home/me(136)> mkdir a
[me@orion]/home/me(137)> cd a
[me@orion]/home/me/a(138)> echo 'echo "$0 here"' >run_me
[me@orion]/home/me/a(139)> chmod 755 run_me
[me@orion]/home/me/a(140)> cd
[me@orion]/home/me(141)> set path=($HOME/a $path)
[me@orion]/home/me(142)> rehash
[me@orion]/home/me(143)> run_me
/home/me/a/run_me here

最新更新