diff options
author | Niels Thykier <niels@thykier.net> | 2017-10-08 14:55:42 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-10-13 18:08:29 +0000 |
commit | 5345f6e92a5529dcaf68919cd0a41aefd1b330c6 (patch) | |
tree | 71bf4979b2688fce3edc40bd69f281e290982098 /dh_installsystemd | |
parent | 773b0357eaecc62297e9ef43653e0df62b1589df (diff) | |
download | debhelper-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-x | dh_installsystemd | 19 |
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); |