From: Torsten Werner Date: Sat, 1 Jan 2011 12:13:13 +0000 (+0100) Subject: avoid 'unbound variable' error in shell script X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce8f55443ccedc1362abe944d582ed33cd95401d;p=dak avoid 'unbound variable' error in shell script Signed-off-by: Torsten Werner --- diff --git a/config/debian/common b/config/debian/common index a42c18ff..f611c19e 100644 --- a/config/debian/common +++ b/config/debian/common @@ -3,11 +3,8 @@ # # Set $PROGRAM to a string to have it added to the output. function log () { - if [ -z "${PROGRAM}" ]; then - echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@" - else - echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@" - fi + local prefix=${PROGRAM:-} + echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@" } # log the message using log() but then also send a mail