diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-03-05 15:18:55 +0100 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-03-05 15:18:55 +0100 |
commit | 6335ba05a97962f6724ff7cc443fc62c2cf9b3fc (patch) | |
tree | 754f48a61a098d53abb386ea6a48bd36b496ab7b | |
parent | 9dda3a026005a13391bbf4526a79275ec2b78c8f (diff) | |
download | sbotools2-6335ba05a97962f6724ff7cc443fc62c2cf9b3fc.tar.xz |
Check if TAGS.txt exists before attempting to open it
-rwxr-xr-x | sbofind | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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+\.?(.*)$/; |