aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2019-04-27 12:55:53 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2019-04-27 12:55:56 +0200
commit389d715aecb0f647aef813d1fc9f201d1b47b9ed (patch)
tree12ef40a8440896833110e754dc8fb84e437a9cb6
parent963cb0b202cec014ec32adb92c29da61ff4fde97 (diff)
downloadsbotools-389d715aecb0f647aef813d1fc9f201d1b47b9ed.tar.xz
sbofind: fix exact matches
Closes #71.
-rwxr-xr-xsbofind8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbofind b/sbofind
index 14e018f..2659076 100755
--- a/sbofind
+++ b/sbofind
@@ -71,8 +71,8 @@ slackbuilds_or_fetch();
sub perform_search {
script_error 'perform_search requires an argument.' unless @_ == 1;
my $search_arg = shift;
- my $search_tag_re = $search_exact ? qr/^(\S+):\s.*\b\Q$search_arg\E\b/i : qr/^(\S+):\s.*\Q$search_arg\E/i;
- my $search_name_re = $search_exact ? "\Q$search_arg\E" : ".*\Q$search_arg\E.*";
+ my $search_tag_re = $search_exact ? qr/^(\S+).*(:\s|,)\b\Q$search_arg\E\b(,|$)/i : qr/^(\S+):\s.*\Q$search_arg\E/i;
+ my $search_name_re = $search_exact ? qr/\Q$search_arg\E/i : qr/.*\Q$search_arg\E.*/i;
# first get a bunch of names from the TAGS.txt if it's available
my $tags_file = "$config{SBO_HOME}/repo/TAGS.txt";
@@ -108,7 +108,7 @@ sub perform_search {
for (reverse @names) { $_ = pop @names if $_ eq $name; }
# next if $name didn't match either one of @names or $search_name_re
- if ($names == @names and $name !~ /$search_name_re/i) { next FIRST; }
+ if ($names == @names and $name !~ $search_name_re) { next FIRST; }
# We only reach this point if $name matched one of @names, or if
# $search_name_re matched
@@ -136,7 +136,7 @@ sub perform_search {
opendir(my $dh, $config{LOCAL_OVERRIDES});
while (my $dir = readdir($dh)) {
next if $local{$dir};
- if ($dir =~ /\Q$search_arg\E/ or in($dir, @names)) {
+ if ($dir =~ $search_name_re or in($dir, @names)) {
push @findings, {name => $dir, location => "$config{LOCAL_OVERRIDES}/$dir", local => 1 };
}
}