From: Steven Baltakatei Sandoval Date: Sun, 28 Jun 2020 16:59:15 +0000 (+0000) Subject: chore(bktemplate):Rename X-Git-Tag: 0.1.0~12 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/1092c1371aa542a04ac9240c1fc10649e6895ecf?ds=sidebyside chore(bktemplate):Rename --- diff --git a/unitproc/bktemplate.sh b/unitproc/bktemplate similarity index 95% rename from unitproc/bktemplate.sh rename to unitproc/bktemplate index 44d3727..df66f70 100755 --- a/unitproc/bktemplate.sh +++ b/unitproc/bktemplate @@ -1,6 +1,6 @@ #!/bin/bash -# Date: 2020-05-04T16:50Z +# Date: 2020-06:19T22:12Z # Author: Steven Baltakatei Sandoval # Description: Template for bash scripts. # Note: Use hide-show-block function to aid readability. (ex: https://www.emacswiki.org/emacs/HideShow ). @@ -17,6 +17,14 @@ SCRIPT_TIME_SHORT="$(date +%Y%m%dT%H%M%S%z)" # Save current date & time in ISO-8 SCRIPT_DATE_SHORT="$(date +%Y%m%d)" # Save current date in ISO-8601 format. #== Function Definitions == + +# Yell, Die, Try Three-Fingered Claw technique +# Ref/Attrib: https://stackoverflow.com/a/25515370 +yell() { echo "$0: $*" >&2; } +die() { yell "$*"; exit 111; } +try() { "$@" || die "cannot $*"; } + + echoerr() { # Usage: echo [ arguments ] # Description: Prints provided arguments to stderr. @@ -55,6 +63,27 @@ vbm() { # End function return 0; # Function finished. } # Verbose message display function. +run() { + # Usage: run [cmd] + # Description: Runs command; reports success if command exit code 0; exits otherwise. + # Input: none + # Output: stdout + # Script function dependencies: none + # Last modified: 2020-06-19T22:09Z + # Last modified by: Steven Baltakatei Sandoval + # License: GPLv3+ + # Ref.Attrib: https://stackoverflow.com/a/18880585 + cmd_output=$(eval $1) + return_value=$? + if [ $return_value != 0 ]; then + echo "Command $1 failed"; + exit -1; + else + echo "output: $cmd_output"; + echo "Command succeeded."; + fi + return $return_value +} # showUsage() { # Usage: showUsage # Description: Displays script usage information.