Bug 20567

Summary: /bin/sh `type' builtin bug
Product: Base System Reporter: David Holland <dholland>
Component: binAssignee: Martin Cracauer <cracauer>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description David Holland 2000-08-12 20:00:03 UTC
	The `type' builtin of sh, if given an absolute pathname,
	prints it concatenated with the first entry in $PATH.

Fix: Patch:
How-To-Repeat: 
	sh -c 'PATH=/bin:/sbin; type /bin/ls'

	prints "/bin/ls is /bin//bin/ls"
Comment 1 Brian Somers 2000-08-12 21:19:24 UTC
> --- 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 !
Comment 2 David Holland 2000-08-13 00:23:27 UTC
 > > --- 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
Comment 3 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-14 10:31:59 UTC
Responsible Changed
From-To: freebsd-bugs->cracauer

Over to the maintainer.
Comment 4 Martin Cracauer freebsd_committer freebsd_triage 2000-08-16 13:08:51 UTC
State Changed
From-To: open->closed

Fixed in -current.  Fix will be merged into 4-stable soon.