Sourcing shell scripts in Perl -
i want source shell script within perl , have environment variables available in perl, i'm not sure if there's elegant way it. obviously, using system()
won't work since runs in forked process, , environment changes lost. think there's cpan module can it, prefer not use external modules.
i've seen 2 solutions not work in case:
have wrapper calls shell script, , calls perl script. not know ahead of time of shell scripts need call.
manually opening shell script , scraping
arg=value
pairs. won't work either because shell script not simple list ofarg=value
, rather contain bunch of conditionals, , variables can have different values depending on conditions.
sh -c "source script; env"
should output environment @ end of script name=value pairs, can parse perl script (as perl language made parsing, should easy).
Comments
Post a Comment