From k-horik@yk.rim.or.jp  Sun Nov  8 08:06:25 1998
Received: from mail.yk.rim.or.jp (mail.yk.rim.or.jp [202.247.130.37])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA23100
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 8 Nov 1998 08:06:24 -0800 (PST)
          (envelope-from k-horik@yk.rim.or.jp)
Received: from localhost (ppp412.yk.rim.or.jp [202.247.165.112])
	by mail.yk.rim.or.jp (8.8.5/3.6W-RIMNET-98-06-09) with ESMTP id BAA00812
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 9 Nov 1998 01:06:09 +0900 (JST)
Message-Id: <19981109010529T.k-horik@yk.rim.or.jp>
Date: Mon, 09 Nov 1998 01:05:29 +0900
From: horikawa@jp.freebsd.org
Sender: Kazuo Horikawa <k-horik@yk.rim.or.jp>
Reply-To: horikawa@jp.freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: symlink(7) manpage says that file(1) has -h option.
X-Send-Pr-Version: 3.2

>Number:         8602
>Category:       docs
>Synopsis:       symlink(7) manpage says that file(1) has -h option.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov  8 08:10:01 PST 1998
>Closed-Date:    Wed Apr 14 11:45:12 PDT 1999
>Last-Modified:  Wed Apr 14 11:45:25 PDT 1999
>Originator:     Kazuo Horikawa
>Release:        FreeBSD 2.2.7-RELEASE i386
>Organization:
jpman project, Japan FreeBSD users group.
>Environment:

	2.2.7-RELEASE

>Description:

	The symlink(7) manpage describes symbolic link handling of
	file(1) command.  But it is not correct.

	1) file(1) command does not have -h option, while symlink(7)
	  manpage says that file(1) has -h options.
	2) file(1) command does not follow symbolic links named as
	  command line arguments by default, while symlink(7) manpage
	  says that ``Except as noted below, commands follow symbolic
	  links named as command line arguments.''
	3) file(1) command does follow sumbolic links named as command
	  line arguments if -L option is specified.

	``man 7 symlink'' says:
[snip]
   Commands not traversing a file tree.
     The second area is symbolic links, specified as command line file name
     arguments, to commands which are not traversing a file tree.

     Except as noted below, commands follow symbolic links named as command
     line arguments.  For example, if there were a symbolic link ``slink''
     which pointed to a file named ``afile'', the command ``cat slink'' would
     display the contents of the file ``afile''.

     It is important to realize that this rule includes commands which may op-
     tionally traverse file trees, e.g. the command ``chown file'' is included
     in this rule, while the command ``chown -R file'' is not.  (The latter is
     described in the third area, below.)

     If it is explicitly intended that the command operate on the symbolic
     link instead of following the symbolic link, e.g., it is desired that
     ``file slink'' display the type of file that ``slink'' is, whether it is
     a symbolic link or not, the -h option should be used.  In the above exam-
     ple, ``file slink'' would report the type of the file referenced by
     ``slink'', while ``file -h slink'' would report that ``slink'' was a sym-
     bolic link.
[snip]

	I think that file(1) command is also exception like mv(1),
	rm(1) and ls(1), because file(1) command does not follow
	symbolic links by default.

>How-To-Repeat:

	% /usr/bin/file -h /tmp/z
	file: illegal option -- h
	Usage: file [-vczL] [-f namefile] [-m magicfiles] file...
	% /usr/bin/file /tmp/z
	/tmp/z: symbolic link to /tmp/a
	% /usr/bin/file -L /tmp/z
	/tmp/z: ASCII text

>Fix:

	Apply following patch for src/bin/ln/symlink.7, or adopt
	file(1) command which has -h option and follows symbolic links
	by default (like file(1) command in BSD 4.4 Lite).
	
--- symlink.7.bak	Mon Nov  9 00:12:52 1998
+++ symlink.7	Mon Nov  9 00:47:07 1998
@@ -160,25 +160,7 @@
 is not.
 (The latter is described in the third area, below.)
 .Pp
-If it is explicitly intended that the command operate on the symbolic
-link instead of following the symbolic link, e.g., it is desired that
-.Dq Li "file slink"
-display the type of file that
-.Dq Li slink
-is, whether it is a symbolic link or not, the
-.Fl h
-option should be used.
-In the above example,
-.Dq Li "file slink"
-would report the type of the file referenced by
-.Dq Li slink ,
-while
-.Dq Li "file -h slink"
-would report that
-.Dq Li slink
-was a symbolic link.
-.Pp
-There are three exceptions to this rule.
+There are four exceptions to this rule.
 The
 .Xr mv 1
 and
@@ -219,12 +201,23 @@
 a file tree.)
 .Pp
 The
+.Xr file 1
+command is also an exception to this rule.
+The
+.Xr file 1
+command does not follow symbolic links named as argument by default.
+The 
+.Xr file 1
+command does follow symbolic links named as argument if
+.Fl L
+option is specified.
+.Pp
+The
 .Bx 4.4
 system differs from historical 4BSD systems in that the
-.Nm chown ,
-.Nm chgrp
+.Nm chown
 and
-.Nm file
+.Nm chgrp
 commands follow symbolic links specified on the command line.
 .Ss Commands traversing a file tree.
 The following commands either optionally or always traverse file trees:
@@ -302,11 +295,6 @@
 .Dq Li "chown -HR user slink"
 will traverse the file hierarchy rooted in the file pointed to by
 .Dq Li slink .
-Note, the
-.Fl H
-is not the same as the previously discussed
-.Fl h
-flag.
 The
 .Fl H
 flag causes symbolic links specified on the command line to be
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: nik 
State-Changed-When: Wed Apr 14 11:45:12 PDT 1999 
State-Changed-Why:  
Patch committed, thanks. 
>Unformatted:
