aboutsummaryrefslogtreecommitdiff
path: root/sbofind
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-08-29 00:19:33 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-08-29 00:19:33 +0200
commit4cb2076c6208dc181b2a69b6d3bd49a4926530ba (patch)
tree2a9186e705a58ce714f4e5952e30edc3cefb8322 /sbofind
parentd9948975a7bc93871b252aa9c5ac9f513e6f13d4 (diff)
downloadsbotools2-4cb2076c6208dc181b2a69b6d3bd49a4926530ba.tar.xz
sbofind: let get_file_contents use slurp() as well
Diffstat (limited to 'sbofind')
-rwxr-xr-xsbofind11
1 files changed, 3 insertions, 8 deletions
diff --git a/sbofind b/sbofind
index 3702e6e..c43e787 100755
--- a/sbofind
+++ b/sbofind
@@ -13,7 +13,7 @@
use 5.16.0;
use strict;
use warnings FATAL => 'all';
-use SBO::Lib qw/ slackbuilds_or_fetch script_error open_read get_build_queue %config $slackbuilds_txt $repo_path show_version in indent /;
+use SBO::Lib qw/ slackbuilds_or_fetch slurp script_error open_read get_build_queue %config $slackbuilds_txt $repo_path show_version in indent /;
use File::Basename;
use Getopt::Long qw(:config bundling);
@@ -132,13 +132,8 @@ sub perform_search {
sub get_file_contents {
script_error 'get_file_contents requires an argument.' unless @_ == 1;
my $file = shift;
- -f $file or return "$file doesn't exist.\n";
- my ($fh, $exit) = open_read($file);
- if ($exit) {
- warn $fh;
- return();
- }
- my $contents = do {local $/; <$fh>};
+ my $contents = slurp($file);
+ return "Unable to open $file.\n" unless defined $contents;
return "\n" . indent 6, $contents;
}