#!/bin/bash function log () { # if argument is given, echo argument, if stream is piped, echo each line of stream if [ "$verbosity" != 'VERBOSE' ] ; then return 0; fi if [ -n "$1" ]; then echo "$1" else while read line do if [ -n "$line" ]; then echo "$line" fi done fi } function error () { # if argument is given, echo argument to stderr, if stream is piped, echo each line of stream to stderr if [ "$verbosity" = 'SILENT' ]; then return 0; fi if [ -n "$1" ]; then echo "$1" >&2 else while read line do if [ -n "$line" ]; then echo "$line" >&2 fi done fi }