Favourite (whonix?) bash script boilerplate template?

Perhaps get https://github.com/Whonix/Whonix and submodules. Then you’ll have all the packages. Then have a glimpse at various bash scripts.

grep --exclude-dir=.git '#!/bin/bash'

parse cmd example:

usage help:

parse config folder example:

error handler example:

mostly useful conventions:

  • mostly for useful for bigger scripts
  • set -e (to have tight control over exit codes)
  • have an err trap
  • set -o pipefail (when using at least one pipe)

Run scripts through shellcheck and fix whatever makes sense. (Apart from false positives and other non-issues.)

Deepening on task.

  • A very simple script: https://github.com/Whonix/sdwdate/blob/master/usr/lib/sdwdate/suspend-pre
  • a more complex example would be whonixcheck (supports sourceing a config folder, sources the script snippet folder, therefore allows overwriting/extending shell functions, allows to skip shell functions by name (whonixcheck_skip_functions), input detection cli vs gui, and more)

Don’t make it a science. As long as it’s secure, readable and good enough, I don’t think we should to be overly strict.