I would like to source a file in a new tcsh shell.
I can run:
#!/usr/bin/env tcsh
konsole --close -e tcsh -exec "ls -l;exec tcsh"
This will open a new konsole, list all files and keep the shell interactive.
However, when I try:
#!/usr/bin/env tcsh
konsole --close -e tcsh -exec "source /tmp/1234.sh;exec tcsh"
I get all the env variables but not the aliases.
For example: In /tmp/1234.sh: I have:
...
setenv MAYA "/maya/path";
alias may 'source /X/tools/binlinux/myscript.tcsh getDirectory ${MAYA} \!*';
...
Now in my new shell:
$env | grep 'MAYA'
will output the correct "MAYA" environment but:
$may
may: Command not found.
All the aliases don't work
If I execute:
$source /tmp/1234.sh
in the new shell, then all aliases will work fine.
Please note that I am unable to store data in any file such as .tchrc or change the format of the /tmp/1234.sh file.
How can I get the aliases to work in the new shell?
答案 0 :(得分:0)
exec
用新的替换当前的过程。 source
命令在旧进程中运行,而新进程不继承其状态(环境变量除外)。
执行所需操作的最简单方法是设置环境变量,并更改tcshrc文件中该变量的行为。例如:
#!/bin/sh
export FOO=bar
konsole --close -e tcsh
然后在您的tcshrc中进行选择:
if ( $?FOO ) then
setenv MAYA "/maya/path";
alias may 'source /X/tools/binlinux/myscript.tcsh getDirectory ${MAYA} \!*';
endif
没有真正的方法告诉tcsh从另一个位置读取配置。我曾经为此发送过补丁,但被拒绝了。