Skip to content

Instantly share code, notes, and snippets.

View jcbagtas's full-sized avatar
💭
IaC <3 DevOps

JC Bagtas jcbagtas

💭
IaC <3 DevOps
View GitHub Profile
@YakDriver
YakDriver / shell_try_catch.sh
Created February 14, 2018 15:27
Bash Basics: A Robust try/catch/finally for shell scripts
#!/bin/bash
# This script uses traps to create try/catch/finally functionality in shell scripts.
#
# OUTPUT:
#
# Hello! We're reporting live from script
# ./try_catch2.sh: line 23: badcommand: command not found
# ./try_catch2.sh: line 23: exiting with status 127
# It's the end of the line