added var function to print out variable values.
authorFred T. Hamster <fred@gruntose.com>
Wed, 12 Feb 2014 20:00:11 +0000 (15:00 -0500)
committerFred T. Hamster <fred@gruntose.com>
Wed, 12 Feb 2014 20:00:11 +0000 (15:00 -0500)
scripts/core/functions.sh

index 6d2bbe29aba4f4f15193e4e53505db6a2a4d26f0..bc2d1cabf88840ecfa0cb91401eb8e27e083f2de 100644 (file)
@@ -33,6 +33,16 @@ if [ -z "$skip_all" ]; then
     cd "$1"
   }
 
+  # displays the value of a variable in bash friendly format.
+  function var() {
+    local varname="$1"; shift
+    if [ -z "${!varname}" ]; then
+      echo "$varname undefined"
+    else
+      echo "$varname=${!varname}"
+    fi
+  }
+
   function success_sound()
   {
     if [ ! -z "$CLAM_FINISH_SOUND" ]; then