Subject: | config files with DOS line endings do not work in Linux |
Well, I noticed it with DOS line endings but the problem occurs with
any trailing whitespace (at least) with the 'equal' format.
In line 662f there is this code to separate keys and values:
next unless /^\s*(.*?)\s*=\s*(.*)\s*$/;
my ($k, $v) = ($1, $2);
Problem is, the second parentheses is greedy, so the optional \s* at the
end will never have any effect and all trailing whitespace (including
the additional DOS line ending character) gets into $2 and $v.
Because of the \s*$ I suspect this effect is not intentional, ergo a bug.
But it is easy to fix, either by not making it greedy:
next unless /^\s*(.*?)\s*=\s*(.*?)\s*$/; # additional question mark
or with an additional trim:
$v =~ s/\s+$//;
It is very difficult to work around the problem by making sure there is
no trailing whitespace since, well it is "white" and invisible.
I am not sure if I understand what the intent of the second alternative
elsif ($v =~ /\s/) {...}
is that is triggered by the above bug because there is whitespace left
in $v but it also looks suspicious that the resulting @v is not used.
-Michael