From 6335ba05a97962f6724ff7cc443fc62c2cf9b3fc Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Sat, 5 Mar 2016 15:18:55 +0100 Subject: Check if TAGS.txt exists before attempting to open it --- sbofind | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sbofind b/sbofind index 65f05c3..6233587 100755 --- 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+\.?(.*)$/; -- cgit v1.2.3