Bug 28852

Summary: behavior of /bin/sh with -e option looks incorrect
Product: Base System Reporter: mori <mori>
Component: binAssignee: Martin Cracauer <cracauer>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description mori 2001-07-10 01:40:01 UTC
	In sh(1), about '-e' and 'errexit' is follows description.

     -e errexit
             Exit immediately if any untested command fails in non-interactive
             mode.  The exit status of a command is considered to be explicit-
             ly tested if the command is used to control an if, elif, while,
             or until; or if the command is the left hand operand of an ``&&''
             or ``||'' operator.

	But in 'if' statement, if a left command of '&&' failes then
 	exit immediately.

	This behavior is found doing follows command.  And this is found
	only in FreeBSD and NetBSD.

	$ sh -ecx 'if true; then false && true; fi; true'
	+ true
	+ false
	$

	In bash-2.05,

	$ bash -ecx 'if true; then false && true; fi; true'
	+ true
	+ false
	+ true
	$

	In SunOS 5.7's /bin/sh

	$ /bin/sh -ecx 'if true; then false && true; fi; true'
	+ true 
	+ false 
	+ true 

	In SunOS 5.7's /bin/ksh

	$ /bin/ksh -ecx 'if true; then false && true; fi; true'
	+ true
	+ false
	+ true
	$

How-To-Repeat: 	Do follow command, please.
	We expect last 'true', but isn't appeared.

	$ sh -ecx 'if true; then false && true; fi; true'
	+ true
	+ false
	$
Comment 1 dwmalone freebsd_committer freebsd_triage 2001-07-10 10:41:18 UTC
Responsible Changed
From-To: freebsd-bugs->chaucer

Martin has an interest in sh.
Comment 2 dwmalone freebsd_committer freebsd_triage 2001-07-10 10:52:53 UTC
Responsible Changed
From-To: chaucer->cracauer

Spell Martin's name correctly... Martin - this PR contains a sh patch 
and ex 
http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28852 
Comment 3 Martin Cracauer freebsd_committer freebsd_triage 2003-12-28 02:18:01 UTC
State Changed
From-To: open->closed

Fixed in the HEAD.