Fix version output when missing. extensible
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Sat, 16 Oct 2010 23:10:31 +0000 (19:10 -0400)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Sat, 16 Oct 2010 23:10:31 +0000 (19:10 -0400)
plc.d/db

index 644a3ad..6bf6388 100755 (executable)
--- a/plc.d/db
+++ b/plc.d/db
@@ -30,7 +30,7 @@ function extend_db()
        extension=${script##*.}
        version=$(psql -U $PLC_DB_USER --quiet --tuples-only --no-align -c \
                  "SELECT version FROM plc_db_extensions WHERE name='$name' LIMIT 1" \
-                 $PLC_DB_NAME 2>/dev/null | awk '/^[0-9]+$/ { ver=$1 } END { print ver }')
+                 $PLC_DB_NAME 2>/dev/null | awk 'BEGIN { ver=0 } /^[0-9]+$/ { ver=$1 } END { print ver }')
        if [ $version -eq 0 ]; then
            if [ "$extension" = "sql" ] ; then
                dialog " - $script (dbdumped)"