On Thu, Jan 12, 2017 at 12:10:00PM -0500, Cinolt Yuklair wrote:
> I'm currently running OpenBSD 6.0-release and I believe I found  a bug
> in the default shell pdksh.

You're right. This bug has been reported here:

https://marc.info/?t=148076436600001&r=1&w=2

and was fixed in -current about a month ago (revisions 1.64-1.67):

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/bin/ksh/exec.c

On -current your script has the following output:

$ sh errexit.sh
+ [ 1 == 1 ]
+ [ 2 == 1 ]
+ false

> 
> I've written about it in detail in this StackOverflow post:
> http://stackoverflow.com/questions/41614964/ksh-errexit-on-conditional-execution/41617070#41617070
> 
> To summarize, the following script will not correctly terminate on the
> second iteration of the loop:
> 
> set -ex
> for a in 1 2 3; do
>   [ $a == 1 ] || false
> done
> 
> On bash, and apparently more recent shells in general, the script
> terminates on the second iteration.
> 
> I do not have the time to provide a source code fix myself, so I am
> reporting about this on misc.

Reply via email to