When making shell scripts

Use the following commands and include them at the top of your shell script.

set -e
This will make the script break if you do not check the return code immediately after returning.

To ignore errors again, use set +e

set -u
Ensure the variable has been defined.


For more info:

http://www.davidpashley.com/articles/writing-robust-shell-scripts.html
http://julipedia.meroh.net/2010/01/set-e-and-set-x.html

Comments

Popular posts from this blog

Ruby weirdness

Running LXD/LXC on WSL2 with Ubuntu 20.04

Installing pikvm on raspberry pi zero 2 w