From: Steven Baltakatei Sandoval Date: Fri, 16 Jul 2021 23:52:55 +0000 (+0000) Subject: Merge branch 'master' of https://zdv2.bktei.com/gitweb/baltakatei-exdev X-Git-Tag: 0.5.0~56 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/93b687f9df50824f6ac2098bb35318b0fcd14713?hp=10d2c1f3504d98aa8129b2fd846a523790aba810 Merge branch 'master' of https://zdv2.bktei.com/gitweb/baltakatei-exdev --- diff --git a/unitproc/bktemp-yellDieTry b/unitproc/bktemp-yellDieTry new file mode 100644 index 0000000..4295aff --- /dev/null +++ b/unitproc/bktemp-yellDieTry @@ -0,0 +1,21 @@ +#!/bin/bash +# Desc: Defines bash functions yell(), die(), and try(), which are useful for +# indicating where in a script an error occurs. +# Ref/Attrib: [1] Yell, Die, Try Three-Fingered Claw technique https://stackoverflow.com/a/25515370 +# Depends: GNU Coreutils 8.30 + +#==BEGIN Define script parameters== +#==END Define script parameters== + +#===BEGIN Declare local script functions=== +yell() { echo "$0: $*" >&2; } +die() { yell "$*"; exit 111; } +try() { "$@" || die "cannot $*"; } +#===END Declare local script functions=== + +#==BEGIN sample code== +yell "This message should appear in stderr."; +try echo "This message should appear in stdout."; +try eeeecho "This message should appear in an error message in stderr."; +yell "This message should not appear because \"try eeeecho\" failed."; +#==END sample code==