Export comprehension in shell

Source: Internet
Author: User

It has long been assumed that the export-after variables in the shell script will affect the environment variables in the terminal that executes the shell. The concept of environment variables is not unique to the shell, but is owned by the process in Linux, and the Shell interpreter runs as a process, so it has its own environment variables. The main function of Linux is usually as follows:

1 int Main (void)2int main (intChar * *argv) 3 int Main (int.Char char **envp)

The third and final envp is a two-level pointer to the environment variable table, which is commonly used for the first 2 kinds of notation. Executes a program under the shell, which is the Shell fork a child process to exec it, that is, this program is the child process of executing its shell. Also know that the Linux sub-process and the parent process share the code snippet, but the data segment, the stack is owned alone, but the child process is created to inherit the parent process's data segment original content, environment variables are included, so that, The shell-initiated envp of this program is the same as the shell's environment variable content. If you execute another shell script at this time, the export variable is equivalent to modifying its own environment variable table, because the parent-child process environment variable is independent, so when it is executed, the shell that executes it, the environment variable of its parent process, is obviously unaffected.

Export comprehension in shell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.