#!/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 ).
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.
# 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.