[英]Trying to learn the BASH Shell source code,but stuck with environment variables loading
I was curious about how the famous Bourne shell is written.So I started digging into the source code.I understand that,One of the initial things which bash does is it loads the ~/.bash_profile file for the user env. 我很好奇如何编写著名的Bourne shell。因此,我开始深入研究源代码。我了解到,bash所做的最初工作之一就是为用户env加载〜/ .bash_profile文件。 My question is how it loads the environment variables in the current shell.
我的问题是它如何在当前shell中加载环境变量。
In the source code bash-2.0/shell.c
, I found a function call like, 在源代码
bash-2.0/shell.c
,我找到了一个函数调用,
maybe_execute_file ("~/.bash_profile", 1);
Even after digging further I was unable to get the exact logic as of how the values are pushed in environment. 即使进一步研究,我也无法获得有关如何在环境中推送值的确切逻辑。
Neither - it executes it without forking (just like the .
or source
built in command). 都不-它不分叉地执行它(就像
.
或内置命令的source
一样)。 If it forked first then environment variable changes in the subshell wouldn't be visible in the original parent. 如果首先分叉,则子shell中的环境变量更改将在原始父级中不可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.