Program: COPY

Author: Marty Peritsky
E-mail: k3pbu@epix.net (preferred address) or MMTed@aol.com (alternate)


   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Purpose: Copies or concatenates files.                           
                                                                         
Syntax:                                                                  
   COPY /?|/H                                                            
   COPY [optns] dev|srcspec[+srcspec...] [optns] [dev|destspec [optns]]  
                                                                         
   dev          is device AUX, COMn, CON, LPTn, NUL, or PRN              
   srcspec      source device, file or list of files (wildcards allowed) 
   destspec     destination file or device                               
   optns        /A process file as ASCII (Ctrl-Z indicates end-of-file)  
                /B process file as binary (no special handling of Ctrl-Z)
                /C request confirmation before processing                
                /S copy system or hidden files                           
                /V verify that destination was written without errors    
                /W warn if destination file already exists
                /Z zero the high-order bit of every byte in destination  
Examples:                                                                
        COPY fileA+fileB fileC                                           
        COPY *.exe c:mydir                                               

Comments:

This program is similar to (but not identical to) the built-in COPY command 
in that other operating system, denoted (Not Free) DOS or NF-DOS for short.

The COPY command in NF-DOS is simple on the surface, but actually quite
complicated in some of its details. (If you don't believe this, take the 
quiz in Appendix A, below.)

In general, this program is simpler, and obeys the following rules:

1. The default mode is always "binary", not "ascii".

2. Source files are opened in the same order that they appear on the
   command line (ie, left-to-right). If the specification contains wildcards,
   the files are opened in the order in which they appear in the directory.

3. The program will append (concatenate) files if and only if the source
   specifies multiple files and the destination does not. This rule implies
   that the symbol "+" is just a separator, and does not force concatenation.

4. Concatenating a mix of ascii and binary files cannot be specified. In
   other words, the "/a" or "/b" appearing before the source specification
   applies to all the source files.

Usually, this program will perform the same as NF-DOS COPY in simple cases.
Ambiguous or peculiar constructions involving wildcards may produce different
results, generally because the source files are opened in a different order.

Examples where results may differ:

COPY *.C+*.H *.Z
COPY *.C+*.H ALL.Z
COPY *.C Z.*
COPY *.* Z?Z*.Z*


APPENDIX A -- A Short Quiz

Assume that the current directory contains the following files:

UUU.C
VVV.C  VVV.H  VVV.Z
WWW.C  WWW.H
       XXX.H

If you run the following command in (Not Free) DOS, what files result,
and what will each one contain?:

COPY *.C+*.H *.Z

Give up? Try it; you'll probably be surprised at the result, which shows
some subtle complexity in the order in which files are processed.

Second question: Where is this documented?
(Answer: nowhere that I have seen.)


