Subject: Re: bin/32282: set -e - difference between /bin/sh and /bin/ksh
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 12/12/2005 15:30:02
The following reply was made to PR bin/32282; it has been noted by GNATS.

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/32282: set -e - difference between /bin/sh and /bin/ksh
Date: Mon, 12 Dec 2005 15:28:04 +0000

 On Mon, Dec 12, 2005 at 03:05:01AM +0000, pstoeber@uni-potsdam.de wrote:
 > >Number:         32282
 > >Synopsis:       set -e - difference between /bin/sh and /bin/ksh
 
 > $ /bin/sh -c 'set -e; (false); echo $?'
 > 1
 > $ /bin/ksh -c 'set -e; (false); echo $?'
 > $ 
 
 I suspect the posix behaviour is that the shell should exit.
 Since (...) is defined as a method of grouping commands, not as an
 equivalent of sh -c '...', so when it says 'the shell should exit'
 there is only one shell.
 
 However the very similar:
 sh -c 'set -e; (false && true); echo $?'
 should definitely echo 1, since the 'false' doesn't cause the shell
 to exit and () isn't a simple command.  ksh gets this one wrong.
 
 Unfortunately, differenciating between the two cases requires an
 additional bit of information - which cannot easily be passed from
 the child to parent when () is implemented using fork().
 
 	David
 
 -- 
 David Laight: david@l8s.co.uk