Let's say I have a bash function

Yadda() {
  # time-consuming processes that must take place sequentially
  # the result will be appended >> $OUTFILE
  # $OUTFILE is set by the main body of the script
  # No manipulation of variables in the main body
  # Only local-ly defined variables are manipulated
}

Am I allowed to invoke the function as a background job in a subshell? E.g.:

OUTFILE=~/result
for PARM in $PARAMLIST; do
  ( Yadda $PARM ) &
done
wait
cat $OUTFILE

What do you think?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top