[clue] source'ing

Michael J. Hammel mjhammel at graphics-muse.org
Tue Apr 24 14:10:19 MDT 2012


On Tue, 2012-04-24 at 13:15 -0600, David L. Willson wrote:
> Can a perl script "source" a bash script, such that exported variables
> in the bash script are visible in the perl script that called it, or
> do I absolutely have to use some sort of "message in a bottle"?

No.  Sourcing under perl will launch a sub-shell, re: a different
process.  The child env is not inherited by the parent process.

Some simple examples to get around that:
http://stackoverflow.com/questions/3675646/can-we-source-a-shell-script-in-perl-script

http://stackoverflow.com/questions/6829179/how-to-source-a-shell-script-environment-variables-in-perl-script-without-fork

Probably easier to run a parent shell script that sources the other
shell script before running the perl script.
-- 
Michael J. Hammel <mjhammel at graphics-muse.org>



More information about the clue mailing list