diff --git a/ddclient.in b/ddclient.in index 7d244db..d8fbbf8 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3381,7 +3381,7 @@ sub group_hosts_by { my %groups; my %cfgs; for my $h (@$hosts) { - my %cfg = map({ ($_ => $config{$h}{$_}); } grep(exists($config{$h}{$_}), @attrs)); + my %cfg = map({ ($_ => $config{$h}{$_}); } grep(defined($config{$h}{$_}), @attrs)); my $sig = repr(\%cfg, Indent => 0); push(@{$groups{$sig}}, $h); $cfgs{$sig} = \%cfg; diff --git a/t/group_hosts_by.pl b/t/group_hosts_by.pl index 4e2c29f..4cf25a1 100644 --- a/t/group_hosts_by.pl +++ b/t/group_hosts_by.pl @@ -72,7 +72,9 @@ my @test_cases = ( want => [ {cfg => {falsy => 0}, hosts => [$h1]}, {cfg => {falsy => ''}, hosts => [$h2]}, - {cfg => {falsy => undef}, hosts => [$h3]}, + # undef intentionally becomes unset because undef always means "fall back to global or + # default". + {cfg => {}, hosts => [$h3]}, ], }, { @@ -80,8 +82,9 @@ my @test_cases = ( groupby => [qw(maybeunset)], want => [ {cfg => {maybeunset => 'unique'}, hosts => [$h1]}, - {cfg => {maybeunset => undef}, hosts => [$h2]}, - {cfg => {}, hosts => [$h3]}, + # undef intentionally becomes unset because undef always means "fall back to global or + # default". + {cfg => {}, hosts => [$h2, $h3]}, ], }, {