make consistent with POSIX 1003.2, draft 10. Now have two recursive
[unix-history] / usr / src / bin / cp / cp.1
index ba6ad30..afb838b 100644 (file)
-.\" Copyright (c) 1989 The Regents of the University of California.
+.\" Copyright (c) 1989, 1990 The Regents of the University of California.
 .\" All rights reserved.
 .\"
 .\" All rights reserved.
 .\"
-.\" Redistribution and use in source and binary forms are permitted
-.\" provided that the above copyright notice and this paragraph are
-.\" duplicated in all such forms and that any documentation,
-.\" advertising materials, and other materials related to such
-.\" distribution and use acknowledge that the software was developed
-.\" by the University of California, Berkeley.  The name of the
-.\" University may not be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\" %sccs.include.redist.man%
 .\"
 .\"
-.\"    @(#)cp.1        6.4 (Berkeley) %G%
+.\"     @(#)cp.1       6.10 (Berkeley) %G%
 .\"
 .\"
-.TH CP 1 ""
-.UC 4
-.SH NAME
-cp - copy files
-.SH SYNOPSIS
-\fBcp [ \fI-fhip\fB ] source_file target_file
-.sp
-\fBcp [ \fI-fhipr\fB ] source_file ... target_directory
-.ft R
-.SH DESCRIPTION
-The
-.I cp
-utility copies
-.I source_file
-to
-.I target_file
-or, in the second form, one or more
-.IR source_file s
-are copied into the target
-.IR target_directory ,
-retaining their original filenames.
+.Dd 
+.Dt CP 1
+.Os BSD 4
+.Sh NAME
+.Nm cp
+.Nd copy files
+.Sh SYNOPSIS
+.Nm cp
+.Op Fl fhip
+.Ar source_file target_file
+.br
+.Nm cp
+.Op Fl Rfhip
+.Ar source_file ... target_directory
+.Sh DESCRIPTION
+In the first synopsis form,
+.Nm cp
+utility copies the contents of the
+.Ar source_file
+to the
+.Ar target_file
+or, in the second synopsis form,
+the contents of each named
+.Ar source_file(s)
+is copied to the destination
+.Ar target_directory .
+The names of the files themselves are not changed.
 If
 If
-.I cp
-detects an attempt to copy a file to itself, the copy shall fail.
-For each destination file that already exists, its contents are
-overwritten if permissions allow, but its mode, user ID, and group
-ID are unchanged.
-Otherwise, the mode of the
-.I source_file
-is used as modified by the file mode creation mask.
-Appropriate permissions are required for file creation or overwriting.
-.PP
+.Nm cp
+detects an attempt to copy a file to itself, the copy will fail.
 The following options are available:
 The following options are available:
-.TP
-.I -h
+.Tp Fl h
 Forces
 Forces
-.I cp
+.Nm cp
 to follow symbolic links.
 to follow symbolic links.
-.TP
-.I -f
-Force existing destination pathnames to be removed before copying,
-without prompting for confirmation.
-.TP
-.I -i
+Provided for the
+.Fl R
+option which does not follow symbolic links by default.
+.Tp Fl f
+Turns off the
+.Fl i
+option.
+(The last
+.Fl f
+or
+.Fl i
+option overrides any previous specification of either option.)
+.Tp Fl i
 Causes
 Causes
-.I cp
+.Nm cp
 to write a prompt to standard error before copying a file that would
 overwrite an existing file.
 If the response from the standard input begins with the character ``y'',
 to write a prompt to standard error before copying a file that would
 overwrite an existing file.
 If the response from the standard input begins with the character ``y'',
-the file is copied if permissions allow the copy.
-.TP
-.I -p
+the file is copied if permissions allow.
+(The last
+.Fl f
+or
+.Fl i
+option overrides any previous specification of either option.)
+.Tp Fl p
 Causes
 Causes
-.I cp
+.Nm cp
 to preserve in the copy as many of the modification time, access time,
 to preserve in the copy as many of the modification time, access time,
+.\" and file mode as allowed by permissions.
 file mode, user ID, and group ID as allowed by permissions.
 file mode, user ID, and group ID as allowed by permissions.
-.TP
-.I -r
+.Pp
+If the user ID and group ID cannot be preserved, no error message
+is displayed and the exit value is not altered.
+.Pp
+If the source file is set user ID or set group ID, and either the user
+ID or the group ID cannot be preserved, the set user ID and set group
+ID bits are not preserved in the copy's permissions.
+.Tp Fl R
 If
 If
-.I source_file
+.Ar source_file
 designates a directory,
 designates a directory,
-.I cp
+.Nm cp
 copies the directory and the entire subtree connected at that point.
 copies the directory and the entire subtree connected at that point.
-This option also causes symbolic links to be copied, rather than
-indirected through, and for
-.I cp
-to create special files rather than copying them as normal files.
-.PP
+Special file types, such as symbolic links and block and character
+devices, are recreated instead of being copied.
+Created directories have the same mode as the corresponding source
+directory, unmodified by the process' file mode creation mask (umask).
+.Tp Fl r
 The
 The
-.I -i
-option is ignored if the
-.I -f
-option is specified.
-.PP
-Symbolic links are followed unless the
-.I -r
-option is specified, in which case the link itself is copied.
-.PP
-.I Cp
+.Fl r
+option is identical to the
+.Fl R
+option with the exception that it does not treat special files
+differently from regular files.
+Symbolic links are always followed.
+This option has been deprecated.
+.Tp
+.Pp
+For each destination file that already exists, its contents are
+overwritten if permissions allow, but
+.Nm cp
+will not change its mode, user ID, or group ID.
+However, if the file is not being copied by the super-user,
+writing the file may clear the set user ID or set group ID
+permission bits.
+.Pp
+If the destination file does not exist, the mode of the source file is
+used as modified by the file mode creation mask (umask).
+If the source file is either set user ID or set group ID, those
+bits are removed unless the source file and the destination
+file are owned by the same user and group.
+.Pp
+Appropriate permissions are required for file creation or overwriting.
+.Pp
+.Nm Cp
 exits 0 on success, >0 if an error occurred.
 exits 0 on success, >0 if an error occurred.
-.SH "SEE ALSO"
-mv(1), rcp(1), umask(2)
+.Sh SEE ALSO
+.Xr mv 1 ,
+.Xr rcp 1 ,
+.Xr umask 2
+.Sh HISTORY
+The
+.Nm cp
+command appeared in Version 6 AT&T UNIX.