Re: psql exit status with multiple -c or -f - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: psql exit status with multiple -c or -f
Date
Msg-id 20190131.104336.216151174.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: psql exit status with multiple -c or -f  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
List pgsql-hackers
At Thu, 31 Jan 2019 10:37:28 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> wrote in
<20190131.103728.153290385.horiguchi.kyotaro@lab.ntt.co.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



pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: psql exit status with multiple -c or -f
Next
From: Michael Paquier
Date:
Subject: Re: A few new options for vacuumdb