[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] avoid 'unbound variable' error in shell script



Signed-off-by: Torsten Werner <twerner@debian.org>
---
 config/debian/common |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/config/debian/common b/config/debian/common
index a42c18f..f611c19 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
-- 
1.5.6.5


Reply to: