Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Nov 1995 11:15:11 -0800
From:      Norm Hutchinson <norm@frosty.cs.ubc.ca>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/837: test -h evaluates to false on symlink to nonexistant file
Message-ID:  <199511241915.LAA10827@frosty.cs.ubc.ca>
Resent-Message-ID: <199511241920.LAA14640@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 24 11:20:01 PST 1995
>Last-Modified:
>Originator:     Norm Hutchinson
>Organization:
UBC Computer Science
>Release:        FreeBSD 2.0-BUILT-19950603 i386
>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;
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511241915.LAA10827>