From chris@claimlynx.com  Wed Sep 15 15:23:08 2004
Return-Path: <chris@claimlynx.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3507316A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 15 Sep 2004 15:23:08 +0000 (GMT)
Received: from bobcat.claimlynx.com (bobcat.claimlynx.com [208.210.147.75])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E14A243D5D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 15 Sep 2004 15:23:07 +0000 (GMT)
	(envelope-from chris@claimlynx.com)
Received: by bobcat.claimlynx.com (Postfix, from userid 1000)
	id 420246276B; Wed, 15 Sep 2004 10:23:07 -0500 (CDT)
Message-Id: <20040915152307.420246276B@bobcat.claimlynx.com>
Date: Wed, 15 Sep 2004 10:23:07 -0500 (CDT)
From: Chris Johnson <chris@claimlynx.com>
Reply-To: Chris Johnson <chris@claimlynx.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: install command sets improper exit values
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         71769
>Category:       bin
>Synopsis:       install command sets improper exit values
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 15 15:30:23 GMT 2004
>Closed-Date:    Wed Sep 15 19:31:40 GMT 2004
>Last-Modified:  Wed Sep 15 19:31:40 GMT 2004
>Originator:     Chris Johnson
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
>Environment:
System: FreeBSD bobcat.claimlynx.com 4.9-STABLE FreeBSD 4.9-STABLE #2: Sat Feb 21 13:43:17 CST 2004 root@bobcat.claimlynx.com:/usr/obj/usr/src/sys/BOBCAT i386


	
>Description:
	The install command appears to always return (exit with) the value 1,
    regardless of success or an error occuring.  Man page says it exits with
    0 on success, >0 if an error occurs -- and such behavior is standard for
    command line programs.
>How-To-Repeat:
	Run install successfully.  Check exit value.  Run install install
    unsuccessfully.  Check exit value.
>Fix:

	No general work around possible.  Alternatives to installing and checking
    success vary depending on situation, but are generally available although
    problemmatic.


>Release-Note:
>Audit-Trail:

From: Chris Johnson <chris@claimlynx.com>
To: freebsd-gnats-submit@FreeBSD.org, chris@claimlynx.com
Cc:  
Subject: Re: bin/71769: install command sets improper exit values
Date: Wed, 15 Sep 2004 12:45:30 -0500

 Strangely, this seems to be related to running "install" within shell scripts 
 only as it works fine from the command line.  More strange still is that a 
 quick look at the xinstall.c code does not show any way that the exit code can 
 be set to 1!  Is this a /bin/sh problem instead?
 
 Here's my minimal test case for reproducing the problem (with some extra LFs 
 for easier reading):
 
 219 test> cat bar
 
 #!/bin/sh
 /usr/bin/install -d $1
 echo $#
 
 220 test> /bin/sh
 $ /usr/bin/install -d foob
 $ echo $#
 0
 $ exit
 
 221 test> rmdir foob
 
 222 test> bar foob
 1
 
 
 What the devil?
 
 
State-Changed-From-To: open->closed 
State-Changed-By: simon 
State-Changed-When: Wed Sep 15 19:30:00 GMT 2004 
State-Changed-Why:  
Not a bug - you are looking at the wrong variable. 

From sh(1): 
#       Expands to the number of positional parameters. 

?       Expands to the exit status of the most recent pipeline. 

BTW. if install returned non-zero error code all 
install(world|kernel)'s would fail. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=71769 
>Unformatted:
