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
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)
var=value
couples in the child and call eval $(./myprogram)
.
Jan 17, 2015 at 4:03
Actually... I got this to work just now using source
If myprogram
contains:
export VAR=TRUE
then after running source myprogram
your case will work.
export
, but it should be explicitly stated it doesn't answer the literal question. source
doesn't create a child, there is no child here, the original bash
is not a parent process.
Jul 17, 2018 at 8:51
source
works like "including a file". It could help some cases, but it's not a solution to the question "how to export variables back to the parent process".
Sep 21, 2018 at 14:06
source doesn't create a child, there is no child here