mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-26 07:57:58 +00:00
parallel: --env implemented. Test fails, man page missing.
This commit is contained in:
parent
cdb8944aad
commit
1f5be2bb43
|
@ -181,6 +181,11 @@ New in this release:
|
|||
* GNU Parallel is accepted for Ubuntu Quantal.
|
||||
http://packages.ubuntu.com/quantal/parallel
|
||||
|
||||
* Blog post in Japanese by Siguniang.
|
||||
https://siguniang.wordpress.com/2012/09/09/notes-on-gnu-parallel-the-command-line-power-tool/
|
||||
(Siguniang mentions the logo is called 'The Cafe Wall Illusion')
|
||||
http://www.michaelbach.de/ot/ang_cafewall/index.html
|
||||
|
||||
* GNU Parallel, where have you been all my life?
|
||||
http://ssdigit.nothingisreal.com/2012/09/gnu-parallel-where-have-you-been-all-my.html
|
||||
|
||||
|
|
41
src/parallel
41
src/parallel
|
@ -520,6 +520,7 @@ sub options_hash {
|
|||
"arg-sep|argsep=s" => \$::opt_arg_sep,
|
||||
"arg-file-sep|argfilesep=s" => \$::opt_arg_file_sep,
|
||||
"trim=s" => \$::opt_trim,
|
||||
"env=s" => \@::opt_env,
|
||||
"plain" => \$::opt_plain,
|
||||
"profile|J=s" => \@::opt_profile,
|
||||
"pipe|spreadstdin" => \$::opt_pipe,
|
||||
|
@ -595,7 +596,7 @@ sub get_options_from_array {
|
|||
sub parse_options {
|
||||
# Returns: N/A
|
||||
# Defaults:
|
||||
$Global::version = 20120822;
|
||||
$Global::version = 20120903;
|
||||
$Global::progname = 'parallel';
|
||||
$Global::infinity = 2**31;
|
||||
$Global::debug = 0;
|
||||
|
@ -812,6 +813,7 @@ sub parse_options {
|
|||
}
|
||||
|
||||
parse_sshlogin();
|
||||
parse_env_var();
|
||||
|
||||
if(remote_hosts() and ($::opt_X or $::opt_m or $::opt_xargs)) {
|
||||
# As we do not know the max line length on the remote machine
|
||||
|
@ -826,6 +828,27 @@ sub parse_options {
|
|||
open_joblog();
|
||||
}
|
||||
|
||||
sub parse_env_var {
|
||||
# Parse --env and set $Global::envvar
|
||||
# Returns: N/A
|
||||
$Global::envvar = "";
|
||||
my @vars = ();
|
||||
for my $varstring (@::opt_env) {
|
||||
# Split up --env VAR1,VAR2
|
||||
push @vars, split /,/, $varstring;
|
||||
}
|
||||
$Global::envvar =
|
||||
(q{eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null}
|
||||
. q{ && echo }
|
||||
. join("", map { "setenv $_ "
|
||||
. ::shell_quote_scalar(::shell_quote_scalar($ENV{$_})).'\;' } @vars)
|
||||
. q{ || echo }
|
||||
. join("", map { "export $_="
|
||||
. ::shell_quote_scalar(::shell_quote_scalar($ENV{$_})).'\;' } @vars)
|
||||
.q{`;});
|
||||
$Global::envvarlen = length $Global::envvar;
|
||||
}
|
||||
|
||||
sub open_joblog {
|
||||
my $append = 0;
|
||||
if($::opt_resume and not $::opt_joblog) {
|
||||
|
@ -3423,7 +3446,7 @@ sub sshlogin_wrap {
|
|||
my $sshlogin = $self->sshlogin();
|
||||
my $sshcmd = $sshlogin->sshcommand();
|
||||
my $serverlogin = $sshlogin->serverlogin();
|
||||
my $next_command_line = $self->replaced();
|
||||
my $next_command_line = $Global::envvar.$self->replaced();
|
||||
my ($pre,$post,$cleanup)=("","","");
|
||||
if($serverlogin eq ":") {
|
||||
$self->{'sshlogin_wrap'} = $next_command_line;
|
||||
|
@ -3440,12 +3463,14 @@ sub sshlogin_wrap {
|
|||
}
|
||||
# If the remote login shell is (t)csh then use 'setenv'
|
||||
# otherwise use 'export'
|
||||
# We cannot use parse_env_var(), as PARALLEL_SEQ changes
|
||||
# for each command
|
||||
my $parallel_env =
|
||||
q{'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null}
|
||||
. q{ && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\;}
|
||||
. q{ setenv PARALLEL_PID '$PARALLEL_PID'}
|
||||
. q{ || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\;}
|
||||
. q{PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;'};
|
||||
(q{ 'eval `echo $SHELL | grep -E "/(t)?csh" > /dev/null }
|
||||
. q{ && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; }
|
||||
. q{ setenv PARALLEL_PID '$PARALLEL_PID' }
|
||||
. q{ || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\; }
|
||||
. q{ PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' });
|
||||
if($::opt_workdir) {
|
||||
$self->{'sshlogin_wrap'} =
|
||||
($pre . "$sshcmd $serverlogin $parallel_env "
|
||||
|
@ -4202,6 +4227,8 @@ sub len {
|
|||
# Worse than worst case: every char needs to be quoted with \ twice
|
||||
$len *= 4;
|
||||
}
|
||||
# If we are using --env, add the prefix for that, too.
|
||||
$len += $Global::envvarlen;
|
||||
return $len;
|
||||
}
|
||||
|
||||
|
|
|
@ -354,7 +354,8 @@ k, m, g, t, or p which would multiply the size with 1024, 1048576,
|
|||
1000000000, 1000000000000, or 1000000000000000 respectively.
|
||||
|
||||
GNU B<parallel> tries to meet the block size but can be off by the
|
||||
length of one record.
|
||||
length of one record. For performance reasons I<size> should be bigger
|
||||
than a single record.
|
||||
|
||||
I<size> defaults to 1M.
|
||||
|
||||
|
|
|
@ -3,6 +3,19 @@
|
|||
echo '### Test slow arguments generation - https://savannah.gnu.org/bugs/?32834'
|
||||
seq 1 3 | parallel -j1 "sleep 2; echo {}" | parallel -kj2 echo
|
||||
|
||||
echo '### Test --env - https://savannah.gnu.org/bugs/?37351'
|
||||
export TWOSPACES=' 2 spaces '
|
||||
export THREESPACES=" > My brother's 12\" records < "
|
||||
parallel --env TWOSPACES echo 'a"$TWOSPACES"b' ::: 1
|
||||
parallel --env TWOSPACES --env THREESPACES echo 'a"$TWOSPACES"b' 'a"$THREESPACES"b' ::: 2
|
||||
parallel --env TWOSPACES,THREESPACES echo 'a"$TWOSPACES"b' 'a"$THREESPACES"b' ::: 2a
|
||||
parallel -S localhost --env TWOSPACES echo 'a"$TWOSPACES"b' ::: 1
|
||||
parallel -S localhost --env TWOSPACES --env THREESPACES echo 'a"$TWOSPACES"b' 'a"$THREESPACES"b' ::: 2
|
||||
parallel -S localhost --env TWOSPACES,THREESPACES echo 'a"$TWOSPACES"b' 'a"$THREESPACES"b' ::: 2a
|
||||
parallel -S csh@localhost --env TWOSPACES echo 'a"$TWOSPACES"b' ::: 1
|
||||
parallel -S csh@localhost --env TWOSPACES --env THREESPACES echo 'a"$TWOSPACES"b' 'a"$THREESPACES"b' ::: 2
|
||||
parallel -S csh@localhost --env TWOSPACES,THREESPACES echo 'a"$TWOSPACES"b' 'a"$THREESPACES"b' ::: 2a
|
||||
|
||||
echo '### Test too slow spawning'
|
||||
killall -9 burnP6 2>/dev/null
|
||||
seq 1 2 | parallel -j2 -N0 timeout -k 25 26 burnP6 &
|
||||
|
|
Loading…
Reference in a new issue