aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-03-05 15:18:55 +0100
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-03-05 15:18:55 +0100
commit6335ba05a97962f6724ff7cc443fc62c2cf9b3fc (patch)
tree754f48a61a098d53abb386ea6a48bd36b496ab7b
parent9dda3a026005a13391bbf4526a79275ec2b78c8f (diff)
downloadsbotools2-6335ba05a97962f6724ff7cc443fc62c2cf9b3fc.tar.xz
Check if TAGS.txt exists before attempting to open it
-rwxr-xr-xsbofind14
1 files 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+\.?(.*)$/;