[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: expected behavior of --results with -n0
From: |
Ole Tange |
Subject: |
Re: expected behavior of --results with -n0 |
Date: |
Fri, 15 Jul 2016 19:54:17 +0200 |
On Wed, Jul 6, 2016 at 9:30 PM, Joel Uckelman <uckelman@nomic.net> wrote:
> Thus spake Joel Uckelman:
>>
>> When I run this:
>>
>> seq 3 | parallel --results b -n0 echo hey
>>
>> parallel writes me a directory tree like this:
>>
>> [uckelman@scylla tmp]$ tree b
>> b
>> └── 1
>> └── \\0
>> ├── seq
>> ├── stderr
>> └── stdout
>
> I think I figured out why this happens---there is only one input
> source (represented by b/1) and there is only one unique value which
> comes from it, i.e., nothing, due to -n0, which gets represented
> as a null escape, \0.
Close. It is of the thought: What is the correct thing to do?
This:
$ seq 4 | parallel -n2 --results a echo
should give:
a/1/1/1/2/seq
a/1/1/1/2/stderr
a/1/1/1/2/stdout
a/1/3/1/4/seq
a/1/3/1/4/stderr
a/1/3/1/4/stdout
because there are 2 values for each command.
And this:
$ seq 2 | parallel -n1 --results a echo
should give:
a/1/1/seq
a/1/1/stderr
a/1/1/stdout
a/1/2/seq
a/1/2/stderr
a/1/2/stdout
because there is 1 value.
So the question is: What is the correct thing to do when there are 0
values? What should this give:
$ parallel -n0 --results a echo ::: a b c ::: 1 2 3
> It looks like what I want instead is this:
>
> seq 3 | parallel --results b 'echo hey ; true'
>
> Each run gets a unique value from the input, but those arguments are
> all fed to 'true', which safely ignores the arguments it's given.
That would work, however, to keep the correct exit value instead use '|| true'.
seq 3 | parallel --results b 'echo hey || true'
/Ole