From norm@frosty.cs.ubc.ca  Fri Nov 24 11:14:06 1995
Received: from frosty.cs.ubc.ca (frosty.cs.ubc.ca [142.103.10.53])
          by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id LAA14287
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Nov 1995 11:14:05 -0800
Received: (from norm@localhost) by frosty.cs.ubc.ca (8.6.11/8.6.9) id LAA10827; Fri, 24 Nov 1995 11:15:11 -0800
Message-Id: <199511241915.LAA10827@frosty.cs.ubc.ca>
Date: Fri, 24 Nov 1995 11:15:11 -0800
From: Norm Hutchinson <norm@frosty.cs.ubc.ca>
Reply-To: norm@frosty.cs.ubc.ca
To: FreeBSD-gnats-submit@freebsd.org
Subject: test -h evaluates to false on symlink to nonexistant file
X-Send-Pr-Version: 3.2

>Number:         837
>Category:       bin
>Synopsis:       test -h evaluates to false on symlink to nonexistant file
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 24 11:20:01 PST 1995
>Closed-Date:    Sat Feb 17 13:35:46 PST 1996
>Last-Modified:  Sat Feb 17 13:38:29 PST 1996
>Originator:     Norm Hutchinson
>Release:        FreeBSD 2.0-BUILT-19950603 i386
>Organization:
UBC Computer Science
>Environment:

	N/A

>Description:

/bin/test -h foo evaluates to false if foo is a symlink that points to a
file that does not exist.

The test script in /src/bin/test/TEST.csh doesn't check this case.
	

>How-To-Repeat:

	
	ln -s /dev/null/nonexistant foo
	/bin/test -h foo
	echo $status
The result is 1, but should be 0 since foo is a symlink

>Fix:
	
	

Patch for /src/bin/test/test.c and TEST.csh

diff -c test/TEST.csh mtest/TEST.csh
*** test/TEST.csh	Fri Sep 23 19:59:11 1994
--- mtest/TEST.csh	Fri Nov 24 09:46:29 1995
***************
*** 86,91 ****
--- 87,105 ----
  t -z ""
  echo 't -z "foo"'
  t -z "foo"
+ 
+ echo 't -h link to nonexistant file'
+ ln -s nonexistant foo
+ t -h "foo"
+ rm foo
+ echo 't -h link to existant file'
+ ln -s test.c foo
+ t -h "foo"
+ rm foo
+ echo 't -h noexist'
+ t -h noexist
+ echo 't -h test.c'
+ t -h test.c
  
  echo 't "foo"'
  t "foo"
diff -c test/test.c mtest/test.c
*** test/test.c	Mon May 29 17:07:29 1995
--- mtest/test.c	Fri Nov 24 09:38:32 1995
***************
*** 388,394 ****
  		goto filetype;
  	case ISSYMLINK:
  		i = S_IFLNK;
! 		(void)lstat(sp->u.string, &fs->stat);
  		goto filetype;
  	case ISFIFO:
  		i = S_IFIFO;
--- 388,394 ----
  		goto filetype;
  	case ISSYMLINK:
  		i = S_IFLNK;
! 		fs->rcode = lstat(sp->u.string, &fs->stat);
  		goto filetype;
  	case ISFIFO:
  		i = S_IFIFO;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wosch 
State-Changed-When: Sat Feb 17 13:35:46 PST 1996 
State-Changed-Why:  
fixed in revision 1.12 1995/10/28 by ache 

>Unformatted:
