Bug 28852 - behavior of /bin/sh with -e option looks incorrect
Summary: behavior of /bin/sh with -e option looks incorrect
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.3-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Martin Cracauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-07-10 01:40 UTC by mori
Modified: 2003-12-28 02:18 UTC (History)
0 users

See Also:


Attachments
file.diff (1.68 KB, patch)
2001-07-10 01:40 UTC, mori
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.