sbotools2

Maintenance fork of the original sbotools version 2
Log | Files | Refs | README

commit 6335ba05a97962f6724ff7cc443fc62c2cf9b3fc
parent 9dda3a026005a13391bbf4526a79275ec2b78c8f
Author: Andreas Guldstrand <andreas.guldstrand@gmail.com>
Date:   Sat,  5 Mar 2016 15:18:55 +0100

Check if TAGS.txt exists before attempting to open it

Diffstat:
Msbofind | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sbofind b/sbofind @@ -67,15 +67,17 @@ sub perform_search { my $search_arg = shift; # first get a bunch of names from the TAGS.txt if it's available - my ($t_fh, $t_exit) = open_read "$config{SBO_HOME}/repo/TAGS.txt"; + my $tags_file = "$config{SBO_HOME}/repo/TAGS.txt"; my @names; - unless ($t_exit) { - while (my $line = <$t_fh>) { - if ($line =~ /^(\S+):\s.*\Q$search_arg\E/) { - push @names, $1; + if (-r $tags_file) { + my ($t_fh, $t_exit) = open_read "$config{SBO_HOME}/repo/TAGS.txt"; + unless ($t_exit) { + while (my $line = <$t_fh>) { + if ($line =~ /^(\S+):\s.*\Q$search_arg\E/) { + push @names, $1; + } } } - close $t_fh; } my $loc_regex = qr/LOCATION:\s+\.?(.*)$/;