Bash Environment Variables – How to Export Back to Parent Process

bashenvironment-variables

I'm try to export variables back to the parent process.

$ export VAR=FALSE
$ echo $VAR
FALSE

$ ./myprogram  # this will set VAR=TRUE
$ echo $VAR
TRUE  <========== I want to print `TRUE` here

Best Answer

Can't be done. The only reliable way to pass anything to the parent process is to echo it and have the parent process capture it with command substitution.

VAR=$(./myprogram)
Related Question