aboutsummaryrefslogtreecommitdiff
path: root/sbofind
diff options
context:
space:
mode:
authorJ Pipkin <j@dawnrazor.net>2013-01-12 07:14:20 -0600
committerJ Pipkin <j@dawnrazor.net>2013-01-12 07:14:20 -0600
commit32abf3c7e9183cfe79019c748e588496722f7426 (patch)
tree7d9cd861e15595abebdda688fb6066e82febba62 /sbofind
parentb2a26f795d32e398bfc3dbfc13882419bd3ba929 (diff)
parentf177c4e5c4311e696373c77e593df452c7602d13 (diff)
downloadsbotools2-32abf3c7e9183cfe79019c748e588496722f7426.tar.xz
Merge branch 'exit_ask', fixes #41, fixes #37
Diffstat (limited to 'sbofind')
-rwxr-xr-xsbofind12
1 files changed, 10 insertions, 2 deletions
diff --git a/sbofind b/sbofind
index 93e7e36..807f733 100755
--- a/sbofind
+++ b/sbofind
@@ -66,7 +66,11 @@ sub perform_search($) {
my (@findings, $name, $found);
my $name_regex = qr/NAME:\s+(.*\Q$search\E.*)$/i;
my $loc_regex = qr/LOCATION:\s+(.*)$/;
- my $fh = open_read "$config{SBO_HOME}/SLACKBUILDS.TXT";
+ my ($fh, $exit) = open_read "$config{SBO_HOME}/SLACKBUILDS.TXT";
+ if ($exit) {
+ warn $fh;
+ exit $exit;
+ }
FIRST: while (my $line = <$fh>) {
unless ($found) {
$found++, next FIRST if $name = ($line =~ $name_regex)[0];
@@ -85,7 +89,11 @@ sub perform_search($) {
sub get_file_contents($) {
exists $_[0] or script_error 'get_file_contents requires an argument';
-f $_[0] or return "$_[0] doesn't exist.\n";
- my $fh = open_read shift;
+ my ($fh, $exit) = open_read shift;
+ if ($exit) {
+ warn $fh;
+ return;
+ }
my $contents = do {local $/; <$fh>};
for ($contents) {
s/\n/\n /g;