5 things I learned from "How to train your BASH" by Marcin Stożek "Perk"

Bash Slides

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 #

Just pass -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#/



Share on Hacker News
Share on LinkedIn


← Home


Want to learn more?

Sign up to get a digest of my articles and interesting links via email every month.

* indicates required

Please select all the ways you would like to hear from Krzysztof Kula:

You can unsubscribe at any time by clicking the link in the footer of my emails.

I use Mailchimp as a marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.