From: Andrew Chilton Date: Tue, 1 Jul 2008 03:18:07 +0000 (+1200) Subject: Do checking of the config file in a nicer way. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8af8540972a6bac8e31f24c2e1efd1388e86e0bb;p=cil.git Do checking of the config file in a nicer way. --- diff --git a/lib/CIL.pm b/lib/CIL.pm index e2be890..bd01a88 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -162,7 +162,15 @@ sub get_attachments_for { sub read_config_file { my ( $self, $filename ) = @_; - my $cfg = CIL::Utils->parse_cil_file( $filename ); + # since we might not have a '.cil' file yet (in the case where we're calling 'init', + # then we should just return whatever the defaults are + my $cfg; + if ( -f $filename ) { + $cfg = CIL::Utils->parse_cil_file( $filename ); + } + else { + $cfg = $defaults; + } # set some defaults if we don't have any of these foreach my $key ( keys %$defaults ) {