summaryrefslogtreecommitdiff
path: root/modules/ConfigParser.pm
diff options
context:
space:
mode:
authorAdam Mitz <mitza-oci@users.noreply.github.com>2010-05-18 15:27:01 +0000
committerAdam Mitz <mitza-oci@users.noreply.github.com>2010-05-18 15:27:01 +0000
commit809006cbd8638dcaad78aba474390003e672c3f8 (patch)
tree4e76aad1012e42389170a4b510fa1506132c6b81 /modules/ConfigParser.pm
parent05b800c0cea4220dac124e2ba13085549ca8432d (diff)
downloadMPC-809006cbd8638dcaad78aba474390003e672c3f8.tar.gz
ChangeLogTag: Tue May 18 15:13:21 UTC 2010 Adam Mitz <mitza@ociweb.com>
Diffstat (limited to 'modules/ConfigParser.pm')
-rw-r--r--modules/ConfigParser.pm15
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/ConfigParser.pm b/modules/ConfigParser.pm
index ae90bb35..a01b34be 100644
--- a/modules/ConfigParser.pm
+++ b/modules/ConfigParser.pm
@@ -104,14 +104,19 @@ sub preprocess {
## We need to replace $(...) with the equivalent environment variable
## value.
- while($str =~ /\$([\(\w\)]+)/) {
- my $name = $1;
+ while ($str =~ /\$(\?)?([\(\w\)]+)/) {
+ my $optional = $1;
+ my $name = $2;
$name =~ s/[\(\)]//g;
my $val = $ENV{$name};
- ## If the environment variable is not set, we will end up removing
- ## the reference, but we need to warn the user that we're doing so.
if (!defined $val) {
+ if (defined $optional) {
+ $str =~ s/\$\?\S+//;
+ next;
+ }
+ ## If the environment variable is not set, we will end up removing
+ ## the reference, but we need to warn the user that we're doing so.
$val = '';
if (!defined $self->{'warned'}->{$name}) {
$self->diagnostic("$name was used in the configuration file, " .
@@ -121,7 +126,7 @@ sub preprocess {
}
## Do the replacement
- $str =~ s/\$([\(\w\)]+)/$val/;
+ $str =~ s/\$\??([\(\w\)]+)/$val/;
}
return $str;
}