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

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

At Thu, 31 Jan 2019 10:37:28 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote in <20190131(dot)103728(dot)153290385(dot)horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
> > 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.
>
> At least bash behaves exactly the same way to psql for me. (Just
> so there's not confusion, set -e works opposite as you think. I
> always use explcit exit to do that, though).
>
> ===t.sh:
> hoge
> hage
> echo Ho-Ho-Ho
> ===
> $ bash t.sh ; echo $?
> test.sh: line 1: hoge: command not found
> test.sh: line 2: hage: command not found
> Ho-Ho-Ho
> 0
>
> ===t.sh:
> set -e
> hoge
> hage
> echo Ho-Ho-Ho
> ===
> $ bash t.sh ; echo $?
> test.sh: line 2: hage: command not found
> 127

Sorry, that was not so good as an example.

=== t.sh
set -e
ls -impossible
echo HoHoHoHo
===
$ bash ~/test.sh; echo $?
ls: invalid option -- 'e'
Try 'ls --help' for more information.
2

=== without set -e
$ bash ~/test.sh; echo $?
ls: invalid option -- 'e'
Try 'ls --help' for more information.
HoHoHoHo
0

# Wow. ls -impossibl works!

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-01-31 02:03:35 Re: A few new options for vacuumdb
Previous Message Kyotaro HORIGUCHI 2019-01-31 01:37:28 Re: psql exit status with multiple -c or -f