added timestamper function
[feisty_meow.git] / scripts / core / functions.sh
index 48e819050e9cd232955b2f0b0e2e34291ccc176a..6cf06befe3dab0933527c0aee82bb9c59caca2d1 100644 (file)
@@ -32,13 +32,20 @@ if [ -z "$skip_all" ]; then
     if [ -z "$sep" ]; then sep='_'; fi
     date +"%Y$sep%m$sep%d$sep%H%M$sep%S" | tr -d '/\n/'
   }
+
+  # a slightly different but also handy time and date function.  this is
+  # intended for prefixing on log lines, so that each line has the time it
+  # occurred as the first element.
+  function timestamper() {
+    date +"[%Y-%m-%d %H:%M:%S] " | tr -d '/\n/'
+  }
   
   # a wrapper for the which command that finds items on the path.  some OSes
   # do not provide which, so we want to not be spewing errors when that
   # happens.
   function whichable()
   {
-    to_find="$1"; shift
+    local to_find="$1"; shift
     local WHICHER="$(/usr/bin/which which 2>/dev/null)"
 #>&2 echo "got whicher as: $WHICHER"
     if [ $? -ne 0 ]; then