source bash config from perl code
Itay Donenhirsch
itay at bazoo.org
Thu Oct 1 14:25:01 IST 2009
thanks for the tips :)
On Thu, Oct 1, 2009 at 12:57 PM, Tzafrir Cohen <tzafrir at cohens.org.il> wrote:
> On Wed, Sep 30, 2009 at 05:57:39PM +0200, Itay Donenhirsch wrote:
>> here's an idea - change the "callee" script to a bash script which
>> sources the config file, and then call the real perl script. something
>> along:
>>
>> #!/bin/bash
>> source config.env
>> ./script.pl $*
>
> 1. bashism:
>
> you meant:
>
> #!/bin/sh
> . config.env
> ./script.pl $*
>
> 2. What about parameters with spaces?
> s/$*/"$@"/
>
> 3. Save some extra space on the the PID table:
>
> exec ./script.pl
>
> 3. You still need to export the variables to make them available in the
> environment of the shell script:
>
> export $EXPORTED_VARS
>
>
> So, something along the lines of:
>
> #!/bin/sh
>
> # Allow overriding the list in the config: is this a feature or a bug?
> EXPORTED_VARS="foo bar baz"
>
> . config.env
> export $EXPORTED_VARS
>
> 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
>
> _______________________________________________
> Linux-il mailing list
> Linux-il at cs.huji.ac.il
> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>
More information about the Linux-il
mailing list