1

I can see there is parallel command which can do similar to what I want and answer is here: run commands in parallel with exit fail if any command fails

But I am using very minimal vm image and so I can't use parallel .

So Is that possible to run commands in parallel and return exist status fail if any of the command fails in the batch.

Ex.

(npm install --global bower ng-cli) & (cd $1 npm install) & (cd $2 bower install); wait

In the above command if 2nd command fails, it should return exit status fail.

Please let me know if I should provide any more information.

(Worst case) if someone can help me converting above command to parallel command that will be also useful.

undefined
  • 3,464
  • 11
  • 48
  • 90
  • Can you elaborate on why you cannot install GNU Parallel? Is the reason covered on https://oletange.wordpress.com/2018/03/28/excuses-for-not-installing-gnu-parallel/ – Ole Tange Oct 30 '18 at 07:36

1 Answers1

1

Using GNU Parallel:

parallel --halt now,fail=1 ::: \
  "npm install --global bower ng-cli" \
  "cd $1 npm install" \
  "cd $2 bower install" && echo All is OK

It will return with failure as soon as one of the jobs fail.

Ole Tange
  • 31,768
  • 5
  • 86
  • 104
  • You do not have that in your question, and if that really works, then this will too. – Ole Tange Oct 30 '18 at 08:25
  • Yes right, that works but I am getting this warning: `Value "now,fail=1" invalid for option halt (number expected)` though command runs well) I am trying to find help for this. Let me know if u know this already? – undefined Oct 30 '18 at 08:42
  • `--halt now,fail=1` is available from version parallel-20140722. From version parallel-20120822 you can use '--halt 2' instead. – Ole Tange Oct 30 '18 at 14:25