my $cfgvar_re = '[A-Z][0-9a-zA-Z-_]*';
- my $cfgfile = $ENV{'OSSTEST_CONFIG'} || "$ENV{'HOME'}/.xen-osstest/config";
- if (!open C, '<', "$cfgfile") {
- die "$cfgfile $!" unless $!==&ENOENT;
- } else {
- while (<C>) {
- die "missing newline" unless chomp;
- s/^\s*//;
- s/\s+$//;
- next if m/^\#/;
- next unless m/\S/;
- if (m/^($cfgvar_re)\s+(\S.*)$/) {
- $c{$1} = $2;
- } elsif (m/^($cfgvar_re)=\s*\<\<(\'?)(.*)\2\s*$/) {
- my ($vn,$qu,$delim) = ($1,$2,$3);
- my $val = '';
- $!=0; while (<C>) {
- last if $_ eq "$delim\n";
- $val .= $_;
+ my $cfgfiles = $ENV{'OSSTEST_CONFIG'} || "$ENV{'HOME'}/.xen-osstest/config";
+
+ foreach my $cfgfile (split /\:/, $cfgfiles) {
+ if (!open C, '<', "$cfgfile") {
+ die "$cfgfile $!" unless $!==&ENOENT;
+ } else {
+ while (<C>) {
+ die "missing newline" unless chomp;
+ s/^\s*//;
+ s/\s+$//;
+ next if m/^\#/;
+ next unless m/\S/;
+ if (m/^($cfgvar_re)\s+(\S.*)$/) {
+ $c{$1} = $2;
+ } elsif (m/^($cfgvar_re)=\s*\<\<(\'?)(.*)\2\s*$/) {
+ my ($vn,$qu,$delim) = ($1,$2,$3);
+ my $val = '';
+ $!=0; while (<C>) {
+ last if $_ eq "$delim\n";
+ $val .= $_;
+ }
+ die $! unless length $_;
+ die unless $val =~ m/\n$/;
+ if ($qu eq '') {
+ my $reconstruct =
+ "\$val = <<${qu}${delim}${qu}; 1;\n".
+ "${val}${delim}\n";
+ eval $reconstruct or
+ die "$1 here doc ($reconstruct) $@";
+ }
+ $c{$vn} = $val;
+ } elsif (m/^($cfgvar_re)=(.*)$/) {
+ eval "\$c{$1} = ( $2 ); 1;" or die "$1 parsed val ($2) $@";
+ } else {
+ die "bad syntax";
}
- die $! unless length $_;
- die unless $val =~ m/\n$/;
- if ($qu eq '') {
- my $reconstruct =
- "\$val = <<${qu}${delim}${qu}; 1;\n".
- "${val}${delim}\n";
- eval $reconstruct or die "$1 here doc ($reconstruct) $@";
- }
- $c{$vn} = $val;
- } elsif (m/^($cfgvar_re)=(.*)$/) {
- eval "\$c{$1} = ( $2 ); 1;" or die "$1 parsed val ($2) $@";
- } else {
- die "bad syntax";
}
+ close C or die "$cfgfile $!";
}
- close C or die "$cfgfile $!";
}
# dynamic default config settings
========================================
Format of config file ~/.xen-osstest/config (you may set OSSTEST_CONFIG to
-point to a different file):
+point to a different file, or :-separates series of files):
Lines containing:
Name value
#-comments and blank lines are ignored.
For an example see ./standalone-config-example
+Values later in the file, or in a later file, take precedence.
========================================