mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
parallel: Negative positional arguments (no context. No -X).
This commit is contained in:
parent
c0b620c832
commit
f948768a1f
|
@ -631,7 +631,7 @@ sub get_options_from_array {
|
|||
sub parse_options {
|
||||
# Returns: N/A
|
||||
# Defaults:
|
||||
$Global::version = 20130131;
|
||||
$Global::version = 20130212;
|
||||
$Global::progname = 'parallel';
|
||||
$Global::infinity = 2**31;
|
||||
$Global::debug = 0;
|
||||
|
@ -4739,6 +4739,7 @@ sub simple_replace_placeholders {
|
|||
# Merge arguments from records into args for easy access
|
||||
CORE::push @args, @$record;
|
||||
}
|
||||
my $n = $#args+1;
|
||||
# Which replace strings are used?
|
||||
# {#} {} {/} {//} {.} {/.} {n} {n/} {n//} {n.} {n/.}
|
||||
for my $used (keys %{$self->{'replacecount'}}) {
|
||||
|
@ -4747,9 +4748,9 @@ sub simple_replace_placeholders {
|
|||
# {} {/} {//} {.} {/.}
|
||||
$replace{$Global::replace{$used}} =
|
||||
join(" ", map { $_->replace($used) } @args);
|
||||
} elsif($used =~ /^\{(\d+)(|\/|\/\/|\.|\/\.)\}$/) {
|
||||
# {n} {n/} {n//} {n.} {n/.}
|
||||
my $positional = $1; # number if any
|
||||
} elsif($used =~ /^\{(-?\d+)(|\/|\/\/|\.|\/\.)\}$/) {
|
||||
# {n} {n/} {n//} {n.} {n/.} {-n} {-n/} {-n//} {-n.} {-n/.}
|
||||
my $positional = $1 > 0 ? $1 : $n+$1+1;
|
||||
my $replacementfunction = "{".::undef_as_empty($2)."}"; # {} {/} {//} {.} or {/.}
|
||||
# If -q then the replacementstrings will be quoted, too
|
||||
# {1.} -> \{1.\}
|
||||
|
|
|
@ -129,8 +129,10 @@ echo '### --resume -k'
|
|||
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit 0 ::: 0 1 2 3 0 5 6 7
|
||||
|
||||
echo '### Negative replacement strings'
|
||||
parallel -N 6 echo {-1}orrec{1} ::: t B C D E c
|
||||
parallel -N 6 echo {-1}orrect ::: A B C D E c
|
||||
parallel -X -j1 -N 6 echo {-1}orrec{1} ::: t B X D E c
|
||||
parallel -N 6 echo {-1}orrect ::: A B X D E c
|
||||
parallel --colsep ' ' echo '{2} + {4} = {2} + {-1}=' '$(( {2} + {-1} ))' ::: "1 2 3 4"
|
||||
parallel --colsep ' ' echo '{-3}orrect' ::: "1 c 3 4"
|
||||
|
||||
|
||||
EOF
|
||||
|
|
Loading…
Reference in a new issue