Merge branch 'master' of https://zdv2.bktei.com/gitweb/baltakatei-exdev
[BK-2020-03.git] / unitproc / bktemp-yellDieTry
CommitLineData
0ed005b0
SBS
1#!/bin/bash
2# Desc: Defines bash functions yell(), die(), and try(), which are useful for
3# indicating where in a script an error occurs.
4# Ref/Attrib: [1] Yell, Die, Try Three-Fingered Claw technique https://stackoverflow.com/a/25515370
5# Depends: GNU Coreutils 8.30
6
7#==BEGIN Define script parameters==
8#==END Define script parameters==
9
10#===BEGIN Declare local script functions===
11yell() { echo "$0: $*" >&2; }
12die() { yell "$*"; exit 111; }
13try() { "$@" || die "cannot $*"; }
14#===END Declare local script functions===
15
16#==BEGIN sample code==
17yell "This message should appear in stderr.";
18try echo "This message should appear in stdout.";
19try eeeecho "This message should appear in an error message in stderr.";
20yell "This message should not appear because \"try eeeecho\" failed.";
21#==END sample code==