$cmd = ". ./set_env && ./termplexer";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
my $shell_exports='exports.sh'; make_exports($shell_exports); open3(...); sub make_exports { my $file=shift; open(my $fh, '<', $file) or return 0; while(my $line=<$fh>) { $ENV{$1}=$2 if($line=~/^\s*export\s+(?:.+?\s+)?(\w+)=(.*?)\s*$/); } close($fh); return 1; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
my $shell_exports='./exports.sh'; make_exports($shell_exports); open3(...); sub make_exports { my $file=shift; for my $line (`sh -c '. $file && env'`) { chomp($line); my ($k,$v)=split(/=/,$line,2); $ENV{$k}=$v if($k && $v); } return 1; }