Browse Source

Use my log funcs if available, else echo

George Jones 1 year ago
parent
commit
f078020cad
1 changed files with 9 additions and 5 deletions
  1. 9 5
      home/public/snippits/bash/function-template.sh

+ 9 - 5
home/public/snippits/bash/function-template.sh

@@ -1,4 +1,4 @@
-# This is my bash function template.  
+# This is my bash function template.
 #
 # Usage:
 #   source THISFILE
@@ -8,9 +8,13 @@
 #   example foo         # run with one arg
 #   example foo bar     # run with two args
 
-#
-#
 source $HOME/lib/bash/bashutils.sh  # error,warning,...
+# source my log functions or use echo
+source ~/lib/bash/bashutils.sh || \
+    alias info=echo && \
+    alias warn=echo && \
+    alias error=echo
+
 
 ARGV=("$@")
 ARGC=("$#")
@@ -60,10 +64,10 @@ EOF
     else
         echo # do something with ARG2
     fi
-    
+
     cmd="echo $ARG1 $ARG2"
     debug "command: ${cmd}" # export DEBUG=1 for debugging
-    
+
     [[ -v DEBUG ]] && set -x
 
     echo args are $* || warn "something went wrong"