From dholland@sake.eecs.harvard.edu  Sat Aug 12 11:52:09 2000
Return-Path: <dholland@sake.eecs.harvard.edu>
Received: from sake.eecs.harvard.edu (sake.eecs.harvard.edu [140.247.60.62])
	by hub.freebsd.org (Postfix) with ESMTP id ECA3737BA97
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 12 Aug 2000 11:52:01 -0700 (PDT)
	(envelope-from dholland@sake.eecs.harvard.edu)
Received: (from dholland@localhost)
	by sake.eecs.harvard.edu (8.9.3/8.9.3) id OAA17736;
	Sat, 12 Aug 2000 14:51:55 -0400 (EDT)
	(envelope-from dholland)
Message-Id: <200008121851.OAA17736@sake.eecs.harvard.edu>
Date: Sat, 12 Aug 2000 14:51:55 -0400 (EDT)
From: David Holland <dholland@eecs.harvard.edu>
Sender: dholland@sake.eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: /bin/sh `type' builtin bug
X-Send-Pr-Version: 3.2

>Number:         20567
>Category:       bin
>Synopsis:       /bin/sh `type' builtin bug
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cracauer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 12 12:00:03 PDT 2000
>Closed-Date:    Wed Aug 16 14:08:51 MEST 2000
>Last-Modified:  Wed Aug 16 14:09:15 MEST 2000
>Originator:     David A. Holland
>Release:        FreeBSD 4.0-RELEASE i386
>Organization:
eecs.harvard.edu
>Environment:

	4.0-RELEASE, appears to also affect -current.

>Description:

	The `type' builtin of sh, if given an absolute pathname,
	prints it concatenated with the first entry in $PATH.

>How-To-Repeat:

	sh -c 'PATH=/bin:/sbin; type /bin/ls'

	prints "/bin/ls is /bin//bin/ls"

>Fix:

Patch:

--- exec.c.dist	Sat Aug 12 14:42:28 2000
+++ exec.c	Sat Aug 12 14:44:06 2000
@@ -884,7 +884,11 @@
 			entry.cmdtype = cmdp->cmdtype;
 			entry.u = cmdp->param;
 		}
-		else {
+		else if (argv[i][0]=='/') {
+			/* Absolute path. */
+			out1fmt(" is %s\n", argv[i]);
+			continue;
+		} else {
 			/* Finally use brute force */
 			find_command(argv[i], &entry, 0, pathval());
 		}

>Release-Note:
>Audit-Trail:

From: Brian Somers <brian@Awfulhak.org>
To: dholland@eecs.harvard.edu
Cc: FreeBSD-gnats-submit@FreeBSD.org, brian@Awfulhak.org
Subject: Re: bin/20567: /bin/sh `type' builtin bug 
Date: Sat, 12 Aug 2000 21:19:24 +0100

 > --- exec.c.dist	Sat Aug 12 14:42:28 2000
 > +++ exec.c	Sat Aug 12 14:44:06 2000
 > @@ -884,7 +884,11 @@
 >  			entry.cmdtype = cmdp->cmdtype;
 >  			entry.u = cmdp->param;
 >  		}
 > -		else {
 > +		else if (argv[i][0]=='/') {
 > +			/* Absolute path. */
 > +			out1fmt(" is %s\n", argv[i]);
 > +			continue;
 > +		} else {
 >  			/* Finally use brute force */
 >  			find_command(argv[i], &entry, 0, pathval());
 >  		}
 
 This is still wrong (although not as wrong as it currently is) as 
 ``type /x'' returns ``/x'' rather than ``/x not found''.
 -- 
 Brian <brian@Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
       <http://www.Awfulhak.org>                   <brian@[uk.]OpenBSD.org>
 Don't _EVER_ lose your sense of humour !
 
 
 

From: David Holland <dholland@eecs.harvard.edu>
To: brian@Awfulhak.org (Brian Somers)
Cc: dholland@eecs.harvard.edu, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/20567: /bin/sh `type' builtin bug
Date: Sat, 12 Aug 2000 19:23:27 -0400 (EDT)

  > > --- exec.c.dist	Sat Aug 12 14:42:28 2000
  > > +++ exec.c	Sat Aug 12 14:44:06 2000
  > > @@ -884,7 +884,11 @@
  > >  			entry.cmdtype = cmdp->cmdtype;
  > >  			entry.u = cmdp->param;
  > >  		}
  > > -		else {
  > > +		else if (argv[i][0]=='/') {
  > > +			/* Absolute path. */
  > > +			out1fmt(" is %s\n", argv[i]);
  > > +			continue;
  > > +		} else {
  > >  			/* Finally use brute force */
  > >  			find_command(argv[i], &entry, 0, pathval());
  > >  		}
  > 
  > This is still wrong (although not as wrong as it currently is) as 
  > ``type /x'' returns ``/x'' rather than ``/x not found''.
 
 Oops. I knew I was forgetting something...
 
 -- 
    - David A. Holland             |    VINO project home page:
      dholland@eecs.harvard.edu    | http://www.eecs.harvard.edu/vino
 
Responsible-Changed-From-To: freebsd-bugs->cracauer 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Mon Aug 14 02:31:59 PDT 2000 
Responsible-Changed-Why:  
Over to the maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20567 
State-Changed-From-To: open->closed 
State-Changed-By: cracauer 
State-Changed-When: Wed Aug 16 14:08:51 MEST 2000 
State-Changed-Why:  
Fixed in -current.  Fix will be merged into 4-stable soon. 

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