Improve debug mode

This commit is contained in:
Benjamin Renard 2019-03-15 16:27:42 +01:00
parent a33e0bfabc
commit 99bacd9979

View file

@ -115,13 +115,15 @@ id "$PG_USER" > /dev/null 2>&1
[ -z "$PG_DB" ] && PG_DB="$PG_USER"
function psql_get () {
echo "$1"|su - $PG_USER -c "$PSQL_BIN -d "$PG_DB" -t -P format=unaligned"
sql="$1"
debug "Exec 'echo \"$sql\"|su - $PG_USER -c \"$PSQL_BIN -d \"$PG_DB\" -w -t -P format=unaligned\""
echo "$sql"|su - $PG_USER -c "$PSQL_BIN -d "$PG_DB" -w -t -P format=unaligned"
}
function debug() {
if [ $DEBUG -eq 1 ]
then
echo "[DEBUG] $1"
>&2 echo "[DEBUG] $1"
fi
}