From d47e1306ecb4e08c7c6958fea6757338613316e2 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Mon, 26 Nov 2012 21:40:26 +0100 Subject: [PATCH] Fixed bug #37779: Make result file names insensitive to order of input sources when using --header --- src/parallel | 13 ++++++++++--- src/parallel.pod | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/parallel b/src/parallel index 21ac31e4..0a3c9aa1 100755 --- a/src/parallel +++ b/src/parallel @@ -4287,15 +4287,22 @@ sub args_as_filename { my @res = (); for my $rec_ref (@{$self->{'arg_list'}}) { - for my $n (0 .. $#$rec_ref) { + no warnings 'numeric'; + my @header_indexes_sorted = sort { + # Sort headers numerically then asciibetically + $Global::input_source_header{$a} <=> $Global::input_source_header{$b} + or + $Global::input_source_header{$a} cmp $Global::input_source_header{$b} + } 1 .. $#$rec_ref+1; + for my $n (@header_indexes_sorted) { CORE::push(@res, - $Global::input_source_header{$n+1}, + $Global::input_source_header{$n}, map { my $s = $_; $s =~ s/\\/\\\\/g; $s =~ s/\t/\\t/g; $s =~ s/\0/\\0/g; $s =~ s:/:\\_:g; $s; } - $rec_ref->[$n]->orig()); + $rec_ref->[$n-1]->orig()); } } return join "\t", @res; diff --git a/src/parallel.pod b/src/parallel.pod index 3b6ee64c..cf4323b4 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -1014,7 +1014,7 @@ will generate the files: and - parallel --results foo/bar echo {1} {2} ::: 1 2 ::: 3 4 + parallel --results foo/bar echo {1} {2} ::: I II ::: III IIII will generate the files: