token: avoid undef warning if no tokens are configured

Initially the config may not even exist, and so the first token
create would give one then a ugly warning like:
> Use of uninitialized value $raw in split at ..

Handle that case, empty config (where we get '') was fine already, so
explicitly check for definedness, not truthiness.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-04-15 17:13:59 +02:00
parent 0ae051a4d6
commit 856c101e97

View File

@ -12,8 +12,9 @@ my $parse_token_cfg = sub {
my ($filename, $raw) = @_;
my $parsed = {};
my @lines = split(/\n/, $raw);
return $parsed if !defined($raw);
my @lines = split(/\n/, $raw);
foreach my $line (@lines) {
next if $line =~ m/^\s*$/;