Hacker News new | ask | show | jobs
by arendtio 1909 days ago
If you don't mind, this is my base template for Bash scripts:

https://pastebin.com/FYMmnZ0B

At the start it provides a stacktrace function which can also be used to notify you if your script has failed (e.g. via xmpp, e-mail, etc.). It is not my own creation, as I found it somewhere a few years ago, but found it super useful over time.

In addition, there are two versions for checking for dependencies. The first lets you communicate instructions for every tool that is required while the second can be used if you simply want to communicate the list of programs that is missing.

The third part is about named parameters, which can be helpful if you don't want to use positional parameters.