Re: psql exit status with multiple -c or -f

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql exit status with multiple -c or -f
Date: 2019-01-31 03:45:23
Message-ID: 20190131034523.GH13248@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Tue, 18 Dec 2018 10:24:39 -0600, Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:
> I think ON_ERROR_STOP would control whether the script stops, but it should
> fail the exit status should reflect any error in the last command. The
> shell does that even without set -e.

Let me correct my own language:

| I think ON_ERROR_STOP would control whether the script stops, but
| the exit status should reflect any error in the last command. The
| shell does that even without set -e.

What I mean is that "the exit status of the shell reflects the status of the
last command". That's why you'll see at the bottom of shscripts an "exit 0"
which might seem to be implied. Actually falling off the end of the script is
same as "exit" which is same as "exit $?" which may be nonzero if the preceding
command was a conditional/test, like:

for ...
if ...
fi
done
# without this, script will variously "fail" due to conditional evaluating to
# false:
exit 0

So I'm pointing out serious concern if psql would return 0 if last command
failed, a case where it's currently exiting with status 1.

Justin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-01-31 04:20:24 Re: A few new options for vacuumdb
Previous Message David G. Johnston 2019-01-31 03:35:00 Re: psql exit status with multiple -c or -f