blob: 90b49abc0ab0e671a4233b9af02fe5087bd77075 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package Zaptel::Config::Defaults;
#
# Written by Oron Peled <oron@actcom.co.il>
# Copyright (C) 2007, Xorcom
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
# $Id$
#
use strict;
# Use the shell to source a file and expand a given list
# of variables.
sub do_source($@) {
my $file = shift;
my @vars = @_;
my @output = `env -i sh -ec '. $file; export @vars; env'`;
die "$0: Sourcing '$file' exited with $?" if $?;
my %vars;
foreach my $line (@output) {
chomp $line;
my ($k, $v) = split(/=/, $line, 2);
$vars{$k} = $v if grep /^$k$/, @vars;
}
return %vars;
}
1;
|