: Shell


Use shellcheck!

shellcheck is a super useful linter for your shell scripts.

I say shell scripts instead of bash scripts since you should typically avoid using bash to run your scripts, since bash:

  • Includes functionality that isn’t POSIX compliant, which risks portability.
  • Is slower than dash, which is POSIX compliant and includes no extra features.
  • Has idiosyncrasies, typically called bash-isms, that manage to creep their way into regular shell scripts

The above reasons are why you should put #!/bin/sh at the top of your scripts, and not #!/bin/bash. On Debian systems /bin/sh is symlinked to /bin/dash so that your scripts run as fast as possible. On other distros it might be linked to something else, but I highly recommend linking it to dash.