Subject: | Get Filter Ignored for Single Value |
Date: | Mon, 23 Apr 2012 17:11:54 -0700 |
To: | bug-config-gitlike [...] rt.cpan.org |
From: | "David E. Wheeler" <dwheeler [...] cpan.org> |
In Git:
Show quoted text
> git config --get-all user.email
david@justatheory.com
Show quoted text > git config --get user.email
david@justatheory.com
Show quoted text > git config --get user.email foo
Notice that I have only one value for user.email, and it is filtered out when I use the regular expression filter in the command. However, Config::GitLike does not work like this: It only filters if there are multiple values:
if (ref $v) {
my @results;
if (defined $args{filter}) {
if ($args{filter} =~ s/^!//) {
@results = grep { !/$args{filter}/i } @{$v};
}
else {
@results = grep { m/$args{filter}/i } @{$v};
}
}
die "Multiple values" unless @results <= 1;
$v = $results[0];
}
I think it should filter on anything, something like this:
$v = [$v] unless ref $v;
my @results;
if (defined $args{filter}) {
if ($args{filter} =~ s/^!//) {
@results = grep { !/$args{filter}/i } @{$v};
}
else {
@results = grep { m/$args{filter}/i } @{$v};
}
}
die "Multiple values" unless @results <= 1;
$v = $results[0];
Thanks,
David