From aa6de2e5a364f062df3eda6129f5e9285161af3a Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Sat, 2 Mar 2013 03:14:03 -0600 Subject: return 0 instead of undef from get_sbo_location, test return with if instead of with if defined --- SBO-Lib/lib/SBO/Lib.pm | 4 ++-- sboinstall | 2 +- sboupgrade | 2 +- t/test.t | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 9b9c168..770e300 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -326,7 +326,7 @@ sub get_sbo_location { seek $fh, 0, 0; } close $fh; - return keys %locations > 0 ? %locations : undef; + return %locations; } # pull the sbo name from a $location: $config{SBO_HOME}/system/wine, etc. @@ -383,7 +383,7 @@ sub get_available_updates() { FIRST: for my $key (keys @$pkg_list) { my $location = get_sbo_location($$pkg_list[$key]{name}); # if we can't find a location, assume invalid and skip - next FIRST unless defined $location; + next FIRST unless $location; my $version = get_sbo_version $location; if (versioncmp($version, $$pkg_list[$key]{version}) == 1) { push @updates, { diff --git a/sboinstall b/sboinstall index 6bff012..d65831b 100755 --- a/sboinstall +++ b/sboinstall @@ -96,7 +96,7 @@ if ($no_reqs or $non_int) { %locations = get_sbo_location($build_queue); for my $sbo (@$build_queue) { usage_error "Unable to locate $sbo in the SlackBuilds.org tree." unless - defined $locations{$sbo}; + $locations{$sbo}; if ($compat32) { usage_error "-p|--compat32 is not supported with Perl SBos." if $locations{$sbo} =~ qr|/perl/[^/]+$|; diff --git a/sboupgrade b/sboupgrade index 8c5b283..762ce3f 100755 --- a/sboupgrade +++ b/sboupgrade @@ -99,7 +99,7 @@ for my $sbo (@sbos) { $name =~ s/-compat32//; $locations{$sbo} = get_sbo_location($name); usage_error "Unable to locate $sbo in the SlackBuilds.org tree." unless - defined $locations{$sbo}; + $locations{$sbo}; if ($sbo =~ /-compat32$/) { usage_error "compat32 Perl SBos are not supported." if $locations{$sbo} =~ qr|/perl/[^/]+$|; diff --git a/t/test.t b/t/test.t index 3b0b799..6e3bcf3 100755 --- a/t/test.t +++ b/t/test.t @@ -102,7 +102,7 @@ print "completed pseudo-random testing of get_installed_packages 'ALL' \n"; # get_sbo_location tests is(get_sbo_location ('nginx'), "$sbo_home/network/nginx", 'get_sbo_location is good'); -is(get_sbo_location ('omgwtfbbq'), undef, +is(get_sbo_location ('omgwtfbbq'), 0, 'get_sbo_location returns false with not-an-sbo input'); my @finds = qw(nginx gmpc); my %locs = get_sbo_location(@finds); -- cgit v1.2.3