Here's an example of re-invoking brash.exe with different command line options from within a brash script:

if [ "$BRASH_THREAD_COUNT" -lt 100 ]
then

     cmdline="$0"

     for f in "$@" ; do cmdline="$cmdline '$f'" ; done

     brash -threads 100 -c "$cmdline"

     exit $?
fi

In this example, the goal for the re-invocation is increase the thread count over and above the default 40 threads.

As can be seen, the steps are as follows:
1. write some code that detects that re-invocation is necessary -- see the if statement
2. Recompute the command line as a string with each parameter value surrounded by single quotes. See the for statement
3. execute brash with the new options and use the -c option to pass the command line
4. exit or return with same error code, see $?, as brash exited with.

Note that only exported variables will be passed to the child instance of brash. Arrays will not be exported.

 

Last edit: Lowell Boggs, Jr. 2016-08-13