From be2bb2b27d61a39bff6efd890c3d519c39db321e Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Sat, 12 Jan 2013 04:14:03 -0600 Subject: implement failure-dependent exit statuses, ask to proceed if a failure is encountered during the process --- sbofind | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sbofind') 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; -- cgit v1.2.3