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

Bug #1104543 reported by Thorsten Glaser
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Fix Released
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.

Revision history for this message
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
Revision history for this message
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
Revision history for this message
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
Revision history for this message
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
Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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