5 things I learned from "How to train your BASH" by Marcin Stożek "Perk"
Today I've watched a presentation by Marcin Stożek called How to train your BASH and wanted to remember the most interesting points for later.
1. It's best if you follow a style guide #
There seems to be only one though Google Shell Style Guide.
2. You can set Bash to "strict mode" #
It sets more human-friendly defaults and makes sure you won't miss any errors in your scripts.
#!/bin/bash set -euo pipefail IFS=$'\n\t'
3. Shellcheck #
Turns out there is a tool called shellcheck that can help you write scripts that you intended to write. Best thing is that it explains what's wrong and gives you suggestions on how you can fix it.
4. You can enable 'debug mode' when running your script #
-x to the script eg.
> bash -x ./my\_script.sh
5. Use Pure Bash
No one wants to see weird errors when running the script on a new server so it's best if you avoid using external programs in your scripts.
There is much more in the presentation so take a look at it: https://slides.com/perk/jak-wytresowac-basha#/
Feedback or Comments?
Want to learn more?
Sign up to get a digest of my articles and interesting links via email every month.