aboutsummaryrefslogtreecommitdiff
path: root/sbofind
diff options
context:
space:
mode:
authorJ Pipkin <j@dawnrazor.net>2013-01-12 04:14:03 -0600
committerJ Pipkin <j@dawnrazor.net>2013-01-12 04:14:03 -0600
commitbe2bb2b27d61a39bff6efd890c3d519c39db321e (patch)
tree387f0c14a12526c6eb1668b3d588ded1a0472212 /sbofind
parentb2a26f795d32e398bfc3dbfc13882419bd3ba929 (diff)
downloadsbotools2-be2bb2b27d61a39bff6efd890c3d519c39db321e.tar.xz
implement failure-dependent exit statuses, ask to proceed if a failure is encountered during the process
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;