Skip to content

Commit

Permalink
improved the config parser
Browse files Browse the repository at this point in the history
  • Loading branch information
creaktive committed Jun 3, 2022
1 parent 631c93f commit fb1f052
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rainbarf
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,14 @@ sub parse_config {
if (open(my $rcfile, q(<), $rcname)) {
while (<$rcfile>) {
s/\#.*$//x;
s/\s+//gx;
if (/^(?:\-{2})?(\w+(?:=\w+)?)$/x) {
unshift @ARGV => q(--) . $1;
s/^\s+|\s+$//gx;
if (my ($k, $v) = /^(?:\-{2})?(\w+)\s*(?:=\s*(.*))?$/x) {
my $p = '--' . $k;
if ($v) {
$v =~ s/\$(\w+)/$ENV{$1}/gx;
$p .= '=' . $v;
}
unshift @ARGV => $p;
}
}
close $rcfile;
Expand Down

0 comments on commit fb1f052

Please sign in to comment.