mksh: set -e interop with functions (possibly) wrong

Reported by Thorsten Glaser on 2013-01-24
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
High
Thorsten Glaser

Bug Description

POSIX set description says:

   -e
          When this option is on, if a simple command fails for any of the reasons listed in
          [348]Consequences of Shell Errors or returns an exit status value >0, and is not part of the
          compound list following a while, until, or if keyword, and is not a part of an AND or OR list,
          and is not a pipeline preceded by the ! reserved word, then the shell shall immediately exit.

But all pdksh-derived shells including posh do:

tg@blau:~ $ mksh -c 'set -e; bla() { [ -x /nonexistant ] && /nonexistant; }; bla; echo x$?'; echo y$?
x1
y0

Instead of:

tg@freewrt:~ $ ksh93 -c 'set -e; bla() { [ -x /nonexistant ] && /nonexistant; }; bla; echo x$?'; echo y$?
y1

I believe mksh may be too lax returning an error here. Discovered while helping Natureshadow with script corner cases caused by Debian’s damned “set -e” requirement. This should not affect BSD make negatively.

Hm, actually, the turning point is here:

tg@blau:~ $ mksh-R36b -c 'set -e; bla() { [ -x /nonexistant ] && /nonexistant; }; bla; echo x$?'; echo y$?
y1
tg@blau:~ $ mksh-R37 -c 'set -e; bla() { [ -x /nonexistant ] && /nonexistant; }; bla; echo x$?'; echo y$?
x1
y0

This means oksh may not be affected.

Thorsten Glaser (mirabilos) wrote :

Considering this is a regression between R36b and R37, and POSIX (to me) looks like this is wrong, raising severity to important.

tags: added: regression
summary: - pdksh: set -e interop with functions (possibly) wrong
+ mksh: set -e interop with functions (possibly) wrong
Changed in mksh:
importance: Low → High
Thorsten Glaser (mirabilos) wrote :

Fix committed to both mksh R41-stable and CVS HEAD as cid 100511834521EDC159D

Changed in mksh:
assignee: nobody → Thorsten Glaser (mirabilos)
status: New → Fix Committed
Thorsten Glaser (mirabilos) wrote :

This fix was released with mksh R41b (bugfix), R42 (stable release), and uploaded as mksh 40.9.20120630-5 to Debian sid in the hopes of having it migrate to wheezy.

Changed in mksh:
status: Fix Committed → Fix Released
Thorsten Glaser (mirabilos) wrote :

The fix is incomplete and introduces a different regression: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700526

Changed in mksh:
status: Fix Released → In Progress
Thorsten Glaser (mirabilos) wrote :

Fixed in R41c and R42b

Changed in mksh:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.