[debhelper-devel] [debhelper] 11/21: dh_installsystemd: Make open failure a hard error

Niels Thykier nthykier at moszumanska.debian.org
Fri Oct 13 18:27:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 5345f6e92a5529dcaf68919cd0a41aefd1b330c6
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Oct 8 14:55:42 2017 +0000

    dh_installsystemd: Make open failure a hard error
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 dh_installsystemd | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/dh_installsystemd b/dh_installsystemd
index 75f905d..38a18b8 100755
--- a/dh_installsystemd
+++ b/dh_installsystemd
@@ -153,11 +153,9 @@ init(options => {
 
 sub contains_install_section {
 	my ($unit_path) = @_;
-	my $fh;
-	if (!open($fh, '<', $unit_path)) {
-		warning("Cannot open($unit_path) for extracting the Also= line(s)");
-		return;
-	}
+
+	open(my $fh, '<', $unit_path) or error("Cannot open($unit_path) for extracting the Also= line(s)");
+
 	while (my $line = <$fh>) {
 		chomp($line);
 		return 1 if $line =~ /^\s*\[Install\]$/i;
@@ -182,16 +180,11 @@ sub install_unit {
 sub extract_key {
 	my ($unit_path, $key) = @_;
 	my @values;
-	my $fh;
 
-	if ($dh{NO_ALSO}) {
-		return @values;
-	}
+	return @values if $dh{NO_ALSO};
+
+	open(my $fh, '<', $unit_path) or error("Cannot open($unit_path) for extracting the Also= line(s)");
 
-	if (!open($fh, '<', $unit_path)) {
-		warning("Cannot open($unit_path) for extracting the Also= line(s)");
-		return;
-	}
 	while (my $line = <$fh>) {
 		chomp($line);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list