Guangning Yu's Blog

Bash Basics

2019-02-16 17:40:29  |  shell
- assign default value to variable ``` DEFAULT=5 RESULT=${VAR:-$DEFAULT} ``` - trap error exit ``` function rollback() { if [[ $? -ne 0 ]]; then echo "rollback" fi } set -ueo pipefail trap r