chore(bktemplate):Rename
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Sun, 28 Jun 2020 16:59:15 +0000 (16:59 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Sun, 28 Jun 2020 16:59:15 +0000 (16:59 +0000)
unitproc/bktemplate [moved from unitproc/bktemplate.sh with 95% similarity]

similarity index 95%
rename from unitproc/bktemplate.sh
rename to unitproc/bktemplate
index 44d3727fe67bccca5da529e5678d74eee712ef9c..df66f70cfa23b81aa411a00f2c9956a2e15d1a8b 100755 (executable)
@@ -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.