LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 589|回复: 4

请教一下下面这段英文的意思关于bash的Environment File

[复制链接]
发表于 2008-12-23 16:12:43 | 显示全部楼层 |阅读模式
As a general rule, you should put as few definitions as possible in .bash_profile and as many as possible in your environment file. Because definitions add to rather than take away from an environment, there is little chance that they will cause something in a subprocess not to work properly. (An exception might be name clashes if you go overboard with aliases.)


请问第二句:Because definitions add to rather than take away from an environment, there is little chance that they will cause something in a subprocess not to work properly. 是什么意思?


谢谢
发表于 2008-12-23 17:14:35 | 显示全部楼层
作为一般规则, 应当尽可能地在.bash_profile里少加点定义而应尽量在环境文件里(定义).因为定义加在一个环境里还不如从中拿开,有一点可能是它们会带来一些使子进程不会正常工作的东西. (一个例外也许是名字冲突如果你到外面使用别名.)
回复 支持 反对

使用道具 举报

发表于 2008-12-23 17:36:07 | 显示全部楼层
再多贴点
这段话是来自哪里的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-12-23 17:52:55 | 显示全部楼层
Learning bash shell 3ed

3.5.2. The Environment File

Although environment variables will always be known to subprocesses, the shell must be explicitly told which other variables, options, aliases, and so on, are to be communicated to subprocesses. The way to do this is to put all such definitions into the environment file. bash's default environment file is the .bashrc file that we touched on briefly at the beginning of this chapter.

Remember, if you take your definitions out of .bash_profile and put them in .bashrc, you will have to have the line source .bashrc at the end of your .bash_profile so that the definitions become available to the login shell.

The idea of the environment file comes from the C shell's .cshrc file. This is reflected in the choice of the name .bashrc. The rc suffix for initialization files is practically universal throughout the UNIX world.[24]

    [24] According to the folklore, it stands for "run commands" and has its origins in old DEC operating systems.

As a general rule, you should put as few definitions as possible in .bash_profile and as many as possible in your environment file. Because definitions add to rather than take away from an environment, there is little chance that they will cause something in a subprocess not to work properly. (An exception might be name clashes if you go overboard with aliases.)

The only things that really need to be in .bash_profile are environment variables and their exports and commands that aren't definitions but actually run or produce output when you log in. Option and alias definitions should go into the environment file. In fact, there are many bash users who have tiny .bash_profile files, e.g.:

stty stop ^S intr ^C erase ^?

date

source .bashrc


Although this is a small .bash_profile, this user's environment file could be huge.
回复 支持 反对

使用道具 举报

发表于 2008-12-23 18:16:31 | 显示全部楼层
就是说:
定义一般是加入环境,而不是被从环境中剔除,所以他们会影响子进程里的东西令其不能正常运行的机会是很低的

不过说实话,我感觉不到这二者有因果关系
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表