限定了可变带或不带出口 [英] Defining a variable with or without export
问题描述
什么是导出
呢?
之间有什么区别:
出口的name = value
和
的name = value
导出
使得提供给子过程的变量。
这就是
出口的name = value
意味着该变量名称可用来的的任何进程的您从shell进程中运行。如果你想有一个过程,利用这个变量,使用导出
,并从shell中运行的进程。
的name = value
意味着变量范围被限制在壳,和不提供给任何其他过程。您将使用此为(比方说)循环变量,临时变量等。
要注意的是导出变量不将其提供给父进程是非常重要的。也就是说,指定并在衍生进程导出变量不让它在启动它的过程中可用。
What is export
for?
What is the difference between:
export name=value
and
name=value
export
makes the variable available to sub-processes.
That is,
export name=value
means that the variable name is available to any process you run from that shell process. If you want a process to make use of this variable, use export
, and run the process from that shell.
name=value
means the variable scope is restricted to the shell, and is not available to any other process. You would use this for (say) loop variables, temporary variables etc.
It's important to note that exporting a variable doesn't make it available to parent processes. That is, specifying and exporting a variable in a spawned process doesn't make it available in the process that launched it.
这篇关于限定了可变带或不带出口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!