136 private links
A gentle admonishment to use shell scripts where appropriate accept that shell scripts will appear in your codebases and to lean heavily on automated tools, modern features, safety rails, and best practices whenever possible.
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.
Shell Files and Interpreter Invocation
Environment
Comments
Formatting
Features and Bugs
Naming Conventions
Calling Commands
Conclusion
Fail fast, fail noisy.
Parameter expansion is the procedure to get the value from the referenced entity, like expanding a variable to print its value. On expansion time you can do very nasty things with the parameter or its value. These things are described here.