Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Use bash options to make scripts more robust #42

Open
chrisburr opened this issue Oct 31, 2017 · 1 comment
Open

Use bash options to make scripts more robust #42

chrisburr opened this issue Oct 31, 2017 · 1 comment

Comments

@chrisburr
Copy link
Member

The bash lesson should recommend using some options at the top of scripts to make them easier to debug. My personal preference is to start scripts with

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

for the reasons listed here.

@alexpearce
Copy link
Member

Agreed that these are useful. I often prefer to use the long-hand version for each flag, as it's a little more self-documenting: (and Googleable)

set -o errexit -o nounset -o pipefail

On the other hand, these lines are quite a lot like magic, especially the IFS line. Are we willing to explain what they do in the lessons?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants