I ended up going the pg_catalog route, something like (off the top of
my head without a linux machine by to test it)
output=$(psql -d template1 -t -c "select * from pg_database where
datname='testdb'")
if [ -z "$output" ]; then
psql createdb testdb
else
echo 'the db already exists'
fi
I did the exact same thing for the user using pg_user and usename
Jon