Subject: bin/7514: /bin/ls doesn't set exit status properly.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jp@spektr.eu.org>
List: netbsd-bugs
Date: 05/03/1999 08:29:47
>Number:         7514
>Category:       bin
>Synopsis:       /bin/ls doesn't set exit status properly.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May  3 08:05:00 1999
>Last-Modified:
>Originator:     Jorgen Pehrson
>Organization:
none
>Release:        NetBSD 1.3I
>Environment:
pmax - hp300, NetBSD 1.3_beta, NetBSD 1.3.2, NetBSD1.3I


>Description:
	/bin/ls fails to set the correct exit value when it can't stat a file.
	This is true for all the NetBSD platforms I have.
	
	Snip from the man page for ls:
	[..]
	The ls utility exits 0 on success, and >0 if an error occurs.
	[..]

	FreeBSD 3.0, Linux (slackware & debian) sets $? to 1. 
	Solaris, HP-UX, Tru64, CLIX, UNIX v7 sets $? to 2. 
	
>How-To-Repeat:
	Correct:
	ls /etc/passwd
	/etc/passwd
	echo $?
	0
	
	Wrong:
	ls doesntexist
	ls: doesntexist: No such file or directory
	echo $?
	0
>Fix:
	
>Audit-Trail:
>Unformatted: