看到一篇非常有意思的文章export variables,讲述了shell环境变量的用法,其中有一个比较新奇的点,例如我在命令行中直接输入bash可以创建一个新的实例(start a new shell instance).如果普通的变量定义在子进程中输出为空,如果想要将变量传递给子进程就需要export变量。
在stackoverflow看到一篇答案bash

The short answer is that when you type "bash" at a bash prompt, it starts a new bash process.

Bash is a program that reads command and executes them. It can read them from a file, or you can type them from an interactive prompt.

When you run a terminal, it's simply a window that runs bash in interactive mode, possibly reading some initialization code first. When you type "bash" at one of these prompts it simply starts another instance of the bash program (ie: another process), running "inside" the original bash program (process) running in the window. When you exit this new bash program, you will be returned to the original bash program where you can type more commands.

The prompt may or may not be different based on a whole bunch of reasons, many of which can be fine-tuned with bash command line options. Even if the prompt looks the same, you are operating in a different process from the original bash.