redirect stderr of dpkg --version to /dev/null to prevent error output if dpkg is too old (thanks Trent W. Buck!)

This commit is contained in:
Johannes 'josch' Schauer 2020-09-02 22:58:20 +02:00
parent e4a3d2b2c5
commit 65e40c8c34
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1289,8 +1289,14 @@ sub run_setup() {
my $dpkgversion;
{
open my $fh, '-|', 'dpkg', '--robot',
'--version' // error "failed to fork(): $!";
my $pid = open my $fh, '-|' // error "failed to fork(): $!";
if ($pid == 0) {
# redirect stderr to /dev/null to hide error messages from dpkg
# versions before 1.20.0
open(STDERR, '>', '/dev/null')
or error "cannot open /dev/null for writing: $!";
exec 'dpkg', '--robot', '--version';
}
chomp(
$dpkgversion = do { local $/; <$fh> }
);