mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-26 07:57:58 +00:00
parallel: Bash aliases only visible if exec'ed as a single command - not a string.
This commit is contained in:
parent
b9470f8964
commit
f8467c9a6b
30
src/parallel
30
src/parallel
|
@ -6439,7 +6439,7 @@ sub empty_input_wrapper {
|
||||||
my $script =
|
my $script =
|
||||||
::spacefree(0,q{
|
::spacefree(0,q{
|
||||||
if(sysread(STDIN, $buf, 1)) {
|
if(sysread(STDIN, $buf, 1)) {
|
||||||
open($fh, "|-", "@ARGV") || die;
|
open($fh, "|-", @ARGV) || die;
|
||||||
syswrite($fh, $buf);
|
syswrite($fh, $buf);
|
||||||
# Align up to 128k block
|
# Align up to 128k block
|
||||||
if($read = sysread(STDIN, $buf, 131071)) {
|
if($read = sysread(STDIN, $buf, 131071)) {
|
||||||
|
@ -6454,7 +6454,7 @@ sub empty_input_wrapper {
|
||||||
});
|
});
|
||||||
::debug("run",'Empty wrap: perl -e '.::shell_quote_scalar($script)."\n");
|
::debug("run",'Empty wrap: perl -e '.::shell_quote_scalar($script)."\n");
|
||||||
return 'perl -e '.::shell_quote_scalar($script)." ".
|
return 'perl -e '.::shell_quote_scalar($script)." ".
|
||||||
::shell_quote_scalar($Global::shell." -c ".::shell_quote_scalar($command));
|
$Global::shell." -c ".::shell_quote_scalar($command);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub filter_through_compress {
|
sub filter_through_compress {
|
||||||
|
@ -7411,7 +7411,7 @@ sub sshreturn {
|
||||||
$nobasedir =~ s:.*/\./::;
|
$nobasedir =~ s:.*/\./::;
|
||||||
$cd = ::shell_quote_file(::dirname($nobasedir));
|
$cd = ::shell_quote_file(::dirname($nobasedir));
|
||||||
my $rsync_cd = '--rsync-path='.::shell_quote_scalar("cd $wd$cd; rsync");
|
my $rsync_cd = '--rsync-path='.::shell_quote_scalar("cd $wd$cd; rsync");
|
||||||
my $basename = ::shell_quote_scalar(::shell_quote_file(basename($file)));
|
my $basename = ::shell_quote_scalar(::shell_quote_file(::basename($file)));
|
||||||
# --return
|
# --return
|
||||||
# mkdir -p /home/tange/dir/subdir/;
|
# mkdir -p /home/tange/dir/subdir/;
|
||||||
# rsync (--protocol 30) -rlDzR --rsync-path="cd /home/tange/dir/subdir/; rsync"
|
# rsync (--protocol 30) -rlDzR --rsync-path="cd /home/tange/dir/subdir/; rsync"
|
||||||
|
@ -7549,7 +7549,7 @@ sub start {
|
||||||
if(not $pid = ::open3($stdin_fh, ">&OUT", ">&ERR", "-")) {
|
if(not $pid = ::open3($stdin_fh, ">&OUT", ">&ERR", "-")) {
|
||||||
# Each child gets its own process group to make it safe to killall
|
# Each child gets its own process group to make it safe to killall
|
||||||
setpgrp(0,0) || ::die_bug("setpgrp failed");
|
setpgrp(0,0) || ::die_bug("setpgrp failed");
|
||||||
exec("exec $Global::shell -c ".::shell_quote_scalar_default($command))
|
exec($Global::shell,"-c",$command)
|
||||||
|| ::die_bug("open3-$stdin_fh $command");
|
|| ::die_bug("open3-$stdin_fh $command");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7587,24 +7587,32 @@ sub start {
|
||||||
|
|
||||||
sub open3_setpgrp {
|
sub open3_setpgrp {
|
||||||
# Select and run open3_setpgrp_internal/open3_setpgrp_external
|
# Select and run open3_setpgrp_internal/open3_setpgrp_external
|
||||||
# parallel -j0 --timeout 5 '( (sleep {}) & )& sleep 7' ::: {1..55} &
|
|
||||||
# ps -opid,ppid,pgrp,cmd
|
|
||||||
# parallel --timeout 6 -q perl -e 'sleep(1);if(fork()){sleep(30)}while(not fork and $t++<30000){ }' ::: 1
|
|
||||||
# perl -e 'sleep(1);if(fork()){sleep(3)}while(not fork and time-$^T<8){ }'
|
|
||||||
no warnings 'redefine';
|
no warnings 'redefine';
|
||||||
my ($outfh,$name) = ::tmpfile(SUFFIX => ".tst");
|
my ($outfh,$name) = ::tmpfile(SUFFIX => ".tst");
|
||||||
# Test to see if open3(x,x,x,"-") is supported
|
# Test to see if open3(x,x,x,"-") is fully supported
|
||||||
my $script = 'if(not $pid=::open3($i,$o,$e,"-")) { unlink shift }';
|
# Can an exported bash function be called via open3?
|
||||||
qx{ perl -MIPC::Open3 -e '$script' $name 2>/dev/null };
|
my $script = 'if($pid=::open3($i,$o,$e,"-")) { wait; } '.
|
||||||
|
'else { exec("bash","-c","testfun && true"); }';
|
||||||
|
my $bash =
|
||||||
|
::shell_quote_scalar_default(
|
||||||
|
"testfun() { rm $name; }; export -f testfun; ".
|
||||||
|
"perl -MIPC::Open3 -e ".
|
||||||
|
::shell_quote_scalar_default($script)
|
||||||
|
);
|
||||||
|
::debug("init",qq{bash -c $bash 2>/dev/null});
|
||||||
|
qx{ bash -c $bash 2>/dev/null };
|
||||||
if(-e $name) {
|
if(-e $name) {
|
||||||
# Does not support open3(x,x,x,"-")
|
# Does not support open3(x,x,x,"-")
|
||||||
|
# or does not have bash:
|
||||||
# Use (slow) external version
|
# Use (slow) external version
|
||||||
unlink($name);
|
unlink($name);
|
||||||
*open3_setpgrp = \&open3_setpgrp_external;
|
*open3_setpgrp = \&open3_setpgrp_external;
|
||||||
|
::debug("init","open3_setpgrp_external chosen\n");
|
||||||
} else {
|
} else {
|
||||||
# Supports open3(x,x,x,"-")
|
# Supports open3(x,x,x,"-")
|
||||||
# This is 0.5 ms faster to run
|
# This is 0.5 ms faster to run
|
||||||
*open3_setpgrp = \&open3_setpgrp_internal;
|
*open3_setpgrp = \&open3_setpgrp_internal;
|
||||||
|
::debug("init","open3_setpgrp_internal chosen\n");
|
||||||
}
|
}
|
||||||
# The sub is now redefined. Call it
|
# The sub is now redefined. Call it
|
||||||
return open3_setpgrp(@_);
|
return open3_setpgrp(@_);
|
||||||
|
|
Loading…
Reference in a new issue