parallel: -J ./profile, -J /abs/profile, -J configprofile.

parallel: Fixed bug #56558: --rrs with --recend that is not regexp.
This commit is contained in:
Ole Tange 2019-06-26 23:11:33 +02:00
parent e8d7b1627a
commit 2e26627e39
5 changed files with 71 additions and 13 deletions

View file

@ -224,6 +224,10 @@ New in this release:
* {= uq; =} causes the replacement string to be unquoted. Example: parallel echo '{=uq;=}.jpg' ::: '*' * {= uq; =} causes the replacement string to be unquoted. Example: parallel echo '{=uq;=}.jpg' ::: '*'
* --tagstring {=...=} is now evaluated for each line with --linebuffer.
* Use -J ./profile to read a profile in current dir.
* Speedup of startup by 40%: Find the parent shell differerently on GNU/Linux, cache information about the CPU and which setpgrp method to use to make GNU Parallel start 40% faster. * Speedup of startup by 40%: Find the parent shell differerently on GNU/Linux, cache information about the CPU and which setpgrp method to use to make GNU Parallel start 40% faster.
https://techieroop.com/how-to-run-multiple-bash-scripts-in-parallel/ https://techieroop.com/how-to-run-multiple-bash-scripts-in-parallel/

View file

@ -2552,13 +2552,20 @@ sub read_options() {
# --profile overrides default profiles # --profile overrides default profiles
@profiles = (); @profiles = ();
for my $profile (@opt::profile) { for my $profile (@opt::profile) {
# Look for the $profile in . and @Global::config_dirs if($profile =~ m:^\./|^/:) {
# Look for ./profile in .
# Look for /profile in /
push @profiles, grep { -r $_ } $profile;
} else {
# Look for the $profile in @Global::config_dirs
push @profiles, grep { -r $_ } push @profiles, grep { -r $_ }
map { "$_/$profile" } ".", @Global::config_dirs; map { "$_/$profile" } @Global::config_dirs;
}
} }
} }
for my $profile (@profiles) { for my $profile (@profiles) {
if(-r $profile) { if(-r $profile) {
::debug("init","Read $profile\n");
local $/ = "\n"; local $/ = "\n";
open (my $in_fh, "<", $profile) || open (my $in_fh, "<", $profile) ||
::die_bug("read-profile: $profile"); ::die_bug("read-profile: $profile");
@ -8161,11 +8168,26 @@ sub block_length($) {
} }
sub remove_rec_sep($) { sub remove_rec_sep($) {
# Remove --recstart and --recend from $block
# Input:
# $block_ref = reference to $block to be modified
# $recstart = --recstart
# $recend = --recend
# Uses:
# $opt::regexp = Are --recstart/--recend regexp?
# Returns:
# N/A
my ($block_ref,$recstart,$recend) = @_; my ($block_ref,$recstart,$recend) = @_;
# Remove record separator # Remove record separator
if($opt::regexp) {
$$block_ref =~ s/$recend$recstart//gos; $$block_ref =~ s/$recend$recstart//gos;
$$block_ref =~ s/^$recstart//os; $$block_ref =~ s/^$recstart//os;
$$block_ref =~ s/$recend$//os; $$block_ref =~ s/$recend$//os;
} else {
$$block_ref =~ s/\Q$recend$recstart\E//gos;
$$block_ref =~ s/^\Q$recstart\E//os;
$$block_ref =~ s/\Q$recend\E$//os;
}
} }
sub non_blocking_write($) { sub non_blocking_write($) {
@ -8176,7 +8198,7 @@ sub non_blocking_write($) {
my $in = $self->fh(0,"w"); my $in = $self->fh(0,"w");
my $rv = syswrite($in, my $rv = syswrite($in,
substr($self->{'block'},$self->{'block_pos'})); substr($self->{'block'},$self->{'block_pos'}));
if (!defined($rv) && $! == EAGAIN()) { if (!defined($rv) && $! == ::EAGAIN()) {
# would block - but would have written # would block - but would have written
$something_written = 0; $something_written = 0;
# avoid triggering auto expanding block # avoid triggering auto expanding block

View file

@ -1853,30 +1853,36 @@ https://github.com/spion/npm-parallel (Last checked: 2019-01)
B<machma> runs tasks in parallel. It gives time stamped B<machma> runs tasks in parallel. It gives time stamped
output. It buffers in RAM. The examples from README.md: output. It buffers in RAM. The examples from README.md:
# Put shorthand for timestamp in config for the examples
echo '--rpl '\
\''{time} $_=::strftime("%Y-%m-%d %H:%M:%S",localtime())'\' \
> ~/.parallel/machma
echo '--line-buffer --tagstring "{#} {time} {}"' >> ~/.parallel/machma
find . -iname '*.jpg' | find . -iname '*.jpg' |
machma -- mogrify -resize 1200x1200 -filter Lanczos {} machma -- mogrify -resize 1200x1200 -filter Lanczos {}
find . -iname '*.jpg' | find . -iname '*.jpg' |
parallel mogrify -resize 1200x1200 -filter Lanczos {} parallel --bar -Jmachma mogrify -resize 1200x1200 -filter Lanczos {}
cat /tmp/ips | machma -p 2 -- ping -c 2 -q {} cat /tmp/ips | machma -p 2 -- ping -c 2 -q {}
cat /tmp/ips | parallel -j 2 --tag --line-buffer ping -c 2 -q {} cat /tmp/ips | parallel -j2 -Jmachma ping -c 2 -q {}
cat /tmp/ips | cat /tmp/ips |
machma -- sh -c 'ping -c 2 -q $0 > /dev/null && echo alive' {} machma -- sh -c 'ping -c 2 -q $0 > /dev/null && echo alive' {}
cat /tmp/ips | cat /tmp/ips |
parallel --tag 'ping -c 2 -q {} > /dev/null && echo alive' parallel -Jmachma 'ping -c 2 -q {} > /dev/null && echo alive'
find . -iname '*.jpg' | find . -iname '*.jpg' |
machma --timeout 5s -- mogrify -resize 1200x1200 -filter Lanczos {} machma --timeout 5s -- mogrify -resize 1200x1200 -filter Lanczos {}
find . -iname '*.jpg' | find . -iname '*.jpg' |
parallel --timeout 5s mogrify -resize 1200x1200 -filter Lanczos {} parallel --timeout 5s --bar mogrify -resize 1200x1200 -filter Lanczos {}
find . -iname '*.jpg' -print0 | find . -iname '*.jpg' -print0 |
machma --null -- mogrify -resize 1200x1200 -filter Lanczos {} machma --null -- mogrify -resize 1200x1200 -filter Lanczos {}
find . -iname '*.jpg' -print0 | find . -iname '*.jpg' -print0 |
parallel --null mogrify -resize 1200x1200 -filter Lanczos {} parallel --null --bar mogrify -resize 1200x1200 -filter Lanczos {}
https://github.com/fd0/machma (Last checked: 2019-01) https://github.com/fd0/machma (Last checked: 2019-06)
=head2 DIFFERENCES BETWEEN interlace AND GNU Parallel =head2 DIFFERENCES BETWEEN interlace AND GNU Parallel

View file

@ -747,6 +747,24 @@ par_delimiter_space() {
parallel -d " " echo ::: "1 done" parallel -d " " echo ::: "1 done"
} }
par_recend_not_regexp() {
echo '### bug #56558: --rrs with --recend that is not regexp'
echo 'a+b' | parallel -k --pipe --rrs --recend '+' -N1 'cat;echo end'
}
par_profile() {
echo '### Test -J profile, -J /dir/profile, -J ./profile'
echo --tag > testprofile_local
parallel -J ./testprofile_local echo ::: local
rm testprofile_local
echo --tag > testprofile_abs
parallel -J `pwd`/testprofile_abs echo ::: abs
rm testprofile_abs
echo --tag > ~/.parallel/testprofile_config
parallel -J testprofile_config echo ::: config
rm ~/.parallel/testprofile_config
}
export -f $(compgen -A function | grep par_) export -f $(compgen -A function | grep par_)
compgen -A function | grep par_ | LC_ALL=C sort | compgen -A function | grep par_ | LC_ALL=C sort |

View file

@ -616,6 +616,10 @@ par_pipepart_recend_recstart 9
par_pipepart_recend_recstart 10 par_pipepart_recend_recstart 10
par_pipepart_roundrobin ### bug #45769: --round-robin --pipepart gives wrong results par_pipepart_roundrobin ### bug #45769: --round-robin --pipepart gives wrong results
par_pipepart_roundrobin 2 par_pipepart_roundrobin 2
par_profile ### Test -J profile, -J /dir/profile, -J ./profile
par_profile local local
par_profile abs abs
par_profile config config
par_python_children ### bug #49970: Python child process dies if --env is used par_python_children ### bug #49970: Python child process dies if --env is used
par_quote ### Test -q par_quote ### Test -q
par_quote a b par_quote a b
@ -731,6 +735,10 @@ par_read_from_stdin b 6
par_read_from_stdin b 7 par_read_from_stdin b 7
par_read_from_stdin b 8 par_read_from_stdin b 8
par_read_from_stdin b 9 par_read_from_stdin b 9
par_recend_not_regexp ### bug #56558: --rrs with --recend that is not regexp
par_recend_not_regexp aend
par_recend_not_regexp b
par_recend_not_regexp end
par_replace_replacementstring ### Test replace {} par_replace_replacementstring ### Test replace {}
par_replace_replacementstring replace curlies par_replace_replacementstring replace curlies
par_replace_replacementstring replace curlies par_replace_replacementstring replace curlies