From 2f2fba268f469324fb6039063411f34025bebb51 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Mon, 10 Jun 2024 23:23:19 +0200 Subject: [PATCH] parallel: Fixed bug #65840: --dry-run doesn't apply filters. --- src/parallel | 5 +++-- testsuite/tests-to-run/parallel-local-0.3s.sh | 6 ++++++ testsuite/wanted-results/parallel-local-0.3s | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/parallel b/src/parallel index b0757ef6..9747dc53 100755 --- a/src/parallel +++ b/src/parallel @@ -11105,6 +11105,7 @@ sub start($) { if($Global::interactive or $Global::stderr_verbose) { $job->interactive_start(); } + $job->openoutputfiles(); # Must be run after $job->interactive_start(): # $job->interactive_start() may call $job->skip() if($job->{'commandline'}{'skip'} @@ -11112,9 +11113,9 @@ sub start($) { not $job->filter()) { # $job->skip() was called or job filtered $command = "true"; + } else { + $job->print_verbose_dryrun(); } - $job->openoutputfiles(); - $job->print_verbose_dryrun(); my($stdout_fh,$stderr_fh) = ($job->fh(1,"w"),$job->fh(2,"w")); if($opt::dryrun or $opt::sqlmaster) { $command = "true"; } $ENV{'PARALLEL_SEQ'} = $job->seq(); diff --git a/testsuite/tests-to-run/parallel-local-0.3s.sh b/testsuite/tests-to-run/parallel-local-0.3s.sh index 61366dfb..6d6195ed 100644 --- a/testsuite/tests-to-run/parallel-local-0.3s.sh +++ b/testsuite/tests-to-run/parallel-local-0.3s.sh @@ -16,6 +16,12 @@ export -f stdsort # Test amount of parallelization # parallel --shuf --jl /tmp/myjl -j1 'export JOBS={1};'bash tests-to-run/parallel-local-0.3s.sh ::: {1..16} ::: {1..5} +par_filter_dryrun() { + echo 'bug #65840: --dry-run doesnot apply filters' + parallel -k --filter='"{1}" ne "Not"' echo '{1} {2} {3}' ::: Not Is ::: good OK + parallel --dr -k --filter='"{1}" ne "Not"' echo '{1} {2} {3}' ::: Not Is ::: good OK +} + par_uninstalled_sshpass() { echo '### sshpass must be installed for --sshlogin user:pass@host' sshpass=$(command -v sshpass) diff --git a/testsuite/wanted-results/parallel-local-0.3s b/testsuite/wanted-results/parallel-local-0.3s index 687adeb9..96076d7c 100644 --- a/testsuite/wanted-results/parallel-local-0.3s +++ b/testsuite/wanted-results/parallel-local-0.3s @@ -236,6 +236,11 @@ par_file_ending_in_newline ### Hans found a bug giving unitialized variable par_file_ending_in_newline gzip /tmp/parallel_f1 par_file_ending_in_newline gzip '/tmp/parallel_f2 par_file_ending_in_newline ' +par_filter_dryrun bug #65840: --dry-run doesnot apply filters +par_filter_dryrun Is good +par_filter_dryrun Is OK +par_filter_dryrun echo Is good +par_filter_dryrun echo Is OK par_fish ### https://github.com/fish-shell/fish-shell/issues/5582 par_fish OK par_group-by_colsep_space ### --colsep " " should work like ","