diff options
author | J Pipkin <j@dawnrazor.net> | 2013-01-12 07:14:20 -0600 |
---|---|---|
committer | J Pipkin <j@dawnrazor.net> | 2013-01-12 07:14:20 -0600 |
commit | 32abf3c7e9183cfe79019c748e588496722f7426 (patch) | |
tree | 7d9cd861e15595abebdda688fb6066e82febba62 /sbofind | |
parent | b2a26f795d32e398bfc3dbfc13882419bd3ba929 (diff) | |
parent | f177c4e5c4311e696373c77e593df452c7602d13 (diff) | |
download | sbotools2-32abf3c7e9183cfe79019c748e588496722f7426.tar.xz |
Merge branch 'exit_ask', fixes #41, fixes #37
Diffstat (limited to 'sbofind')
-rwxr-xr-x | sbofind | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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; |