I have a Postgres console command createdb appname_production_master, which return error exit code if the database with this name already exists.
Is it possible to make this command do not return any exit code?
Just ignore the exit code, for example like this.
createdb appname_production_master || true
Unix commands always return exit codes, but you need not respond to the exit code.
When you run a command $? is set to the exit code of the process. As this happens for every command, simply running a different command after the first will change $?.
For example:
createdb appname_production_master # returns 1, a failure code
# $? is 1
/bin/true # always returns 0, success
# $? is 0
Here's another example:
/bin/false # returns false, I assume usually 1
echo $? # outputs 1
echo $? # outputs 0, last echo command succeeded