parallel: fixed bug #33995: Jobs executed with sh instead of $SHELL

This commit is contained in:
Ole Tange 2011-09-24 02:35:16 +02:00
parent 9fad573774
commit 986f69db11
3 changed files with 10 additions and 4 deletions

View file

@ -3361,13 +3361,13 @@ sub start {
. $job->seq() . "): $command\n"); . $job->seq() . "): $command\n");
if($::opt_pipe) { if($::opt_pipe) {
my ($in); my ($in);
$pid = ::open3($in, ">&OUT", ">&ERR", $command) || $pid = ::open3($in, ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
::die_bug("open3-pipe"); ::die_bug("open3-pipe");
$job->set_stdin($in); $job->set_stdin($in);
} elsif(@::opt_a and not $Global::stdin_in_opt_a and $job->seq() == 1) { } elsif(@::opt_a and not $Global::stdin_in_opt_a and $job->seq() == 1) {
# Give STDIN to the first job if using -a # Give STDIN to the first job if using -a
*IN = *STDIN; *IN = *STDIN;
$pid = ::open3("<&IN", ">&OUT", ">&ERR", $command) || $pid = ::open3("<&IN", ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
::die_bug("open3-a"); ::die_bug("open3-a");
# Re-open to avoid complaining # Re-open to avoid complaining
open STDIN, "<&", $Global::original_stdin open STDIN, "<&", $Global::original_stdin
@ -3376,12 +3376,12 @@ sub start {
open(DEVTTY, "/dev/tty")) { open(DEVTTY, "/dev/tty")) {
# Give /dev/tty to the command if no one else is using it # Give /dev/tty to the command if no one else is using it
*IN = *DEVTTY; *IN = *DEVTTY;
$pid = ::open3("<&IN", ">&OUT", ">&ERR", $command) || $pid = ::open3("<&IN", ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
::die_bug("open3-/dev/tty"); ::die_bug("open3-/dev/tty");
$Global::tty_taken = $pid; $Global::tty_taken = $pid;
close DEVTTY; close DEVTTY;
} else { } else {
$pid = ::open3(::gensym, ">&OUT", ">&ERR", $command) || $pid = ::open3(::gensym, ">&OUT", ">&ERR", $ENV{SHELL}, "-c", $command) ||
::die_bug("open3-gensym"); ::die_bug("open3-gensym");
} }
$job->set_pid($pid); $job->set_pid($pid);

View file

@ -20,3 +20,6 @@ stdout parallel -k --tag -j1 echo stderr-{.} ">&2;" echo stdout-{} ::: a b
echo '### Test --tag -X ::: a b' echo '### Test --tag -X ::: a b'
stdout parallel -k --tag -X -j1 echo stderr-{.} ">&2;" echo stdout-{} ::: a b stdout parallel -k --tag -X -j1 echo stderr-{.} ">&2;" echo stdout-{} ::: a b
echo '### Test bash redirection <()'
parallel 'cat <(echo {}); echo b' ::: a

View file

@ -17,3 +17,6 @@ b stdout-b
### Test --tag -X ::: a b ### Test --tag -X ::: a b
a b stderr-a stderr-b a b stderr-a stderr-b
a b stdout-a stdout-b a b stdout-a stdout-b
### Test bash redirection <()
a
b