19763 shaares
136 private links
136 private links
Notice the line makepdf & makedoc & openapp. Here I am are running the 3 functions in parallel. The wait command does exactly that, waiting for the previous things to finish. When everything is done, the pdf file opens. Let’s look at the timing now:
real 0m24.677s
user 0m21.669s
sys 0m1.746s
It is running ~27% faster. Only by wrapping the code in different functions.
As an extra, in bash the code is not evaluated all at once. If you edit a script while it is being executed, the script behaves differently. Wrapping it in functions solves that problem too.