Thursday, 17 August 2017

Bash Exporting A Variable

Cited from the Book "Pro Bash Programming"

There is no need to export a variable unless you want to make it available to scripts (or other programs) called from the current script (and their children and their children’s children and...). Exporting a variable doesn’t make it visible anywhere except child processes.

Once a variable is exported, it remains in the environment until it is unset.

In bash, reassignment doesn't remove a variable from the environment.

Variables set in a subshell are not visible to the script that called it. Subshells include command substitution, as in $(command); all elements of a pipeline; and code enclosed in parentheses, as in '(' command ')'.





No comments:

Post a Comment