6

I want to do the following from the tcsh command line, preferably in 1 line:

build_cmd1 &
build_cmd2 &
build_cmd3 &
wait until all parallel build commands finish
regression_cmd

That is, I want to fork off a bunch of build commands, block until they exit, and then run another command. I want to do this from the tcsh command line.

Ross Rogers
  • 4,807

1 Answers1

4

::checks with the man pages::

It looks like csh and derivatives support wait, so consider something like

% cmd1 &; cmd2 &; cmd3 &; wait; thing_to_do_after

or because the && and || operators short-circuit you could use

% (cmd1 &; cmd2 &; cmd3 &) && thing_to_do_after

but only if you are certain of the exit state of the subshell (true means use && and false means use ||).

If you want the wait to be impervious to previously launched background tasks put it in the subshell (()) like this:

% (cmd1 &; cmd2 &; cmd3 &; wait) && thing_to_do_after

or

% (cmd1 &; cmd2 &; cmd3 &; wait; thing_to_do_after)

//please be aware that I haven't used tcsh in ages...