summaryrefslogtreecommitdiff
path: root/dh_installsystemd
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-10-08 14:55:42 +0000
committerNiels Thykier <niels@thykier.net>2017-10-13 18:08:29 +0000
commit5345f6e92a5529dcaf68919cd0a41aefd1b330c6 (patch)
tree71bf4979b2688fce3edc40bd69f281e290982098 /dh_installsystemd
parent773b0357eaecc62297e9ef43653e0df62b1589df (diff)
downloaddebhelper-5345f6e92a5529dcaf68919cd0a41aefd1b330c6.tar.gz
dh_installsystemd: Make open failure a hard error
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_installsystemd')
-rwxr-xr-xdh_installsystemd19
1 files changed, 6 insertions, 13 deletions
diff --git a/dh_installsystemd b/dh_installsystemd
index 75f905de..38a18b89 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);