parallel: Fixed bug #58802: --results unreliable under Cygwin.

This commit is contained in:
Ole Tange 2020-07-23 10:31:08 +02:00
parent 22cc1f06e6
commit d8f99bf85f

View file

@ -5323,7 +5323,6 @@ sub qqx(@) {
# and STDERR ignored # and STDERR ignored
# This is needed if the environment contains functions # This is needed if the environment contains functions
# that /bin/sh does not understand # that /bin/sh does not understand
my $PATH = $ENV{'PATH'};
my %env; my %env;
# ssh with ssh-agent needs PATH SSH_AUTH_SOCK SSH_AGENT_PID # ssh with ssh-agent needs PATH SSH_AUTH_SOCK SSH_AGENT_PID
# ssh with Kerberos needs KRB5CCNAME # ssh with Kerberos needs KRB5CCNAME
@ -5334,23 +5333,13 @@ sub qqx(@) {
local %ENV; local %ENV;
%ENV = %env; %ENV = %env;
if($Global::debug) { if($Global::debug) {
# && true is to force spawning a shell and not just exec'ing
return qx{ @_ && true }; return qx{ @_ && true };
} else { } else {
if($^O eq "cygwin") { local *STDERR;
# CygWin does not respect 2>/dev/null
# so we do that by hand
open my $original_stderr, ">&", "STDERR" or
::die_bug("Can't dup STDERR: $!");
close STDERR;
open(STDERR, ">", "/dev/null"); open(STDERR, ">", "/dev/null");
my @ret = qx{ @_ }; # && true is to force spawning a shell and not just exec'ing
close STDERR; return qx{ @_ && true };
open STDERR, ">&", $original_stderr or
::die_bug("Can't dup STDERR: $!");
return wantarray ? @ret : join "",@ret;
} else {
return qx{ ( @_ ) 2>/dev/null };
}
} }
} }