source bash config from perl code

source bash config from perl code

Tzafrir Cohen tzafrir at cohens.org.il
Sat Oct 3 16:56:49 IST 2009


On Fri, Oct 02, 2009 at 08:59:37AM +0200, Noam Meltzer wrote:
> On Thu, Oct 1, 2009 at 12:57 PM, Tzafrir Cohen <tzafrir at cohens.org.il>wrote:
> 
> >
> > 3. You still need to export the variables to make them available in the
> > environment of the shell script:
> >
> >  export $EXPORTED_VARS
> >
> >
> Well, not necessarily.
> At least in bash (I didn''t check /bin/sh) , you can use 'set -a' to
> automatically mark variables and functions which are modified or created for
> export to the environment of subsequent commands. (so knowing the variables
> ahead is not a must)

I didn't check standards, but it is supported by dash, posh and busybox
ash as well here.

> 
> so:
> #!/bin/bash
> set -a
> . config.env
> exec ./script.pl "$@"


-- 
Tzafrir Cohen         | tzafrir at jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir at cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend



More information about the Linux-il mailing list