bin/50656: /bin/cp - wrong error on copying of multiple files

Edwin Groothuis edwin at mavetju.org
Sun Apr 6 16:00:37 PDT 2003


>Number:         50656
>Category:       bin
>Synopsis:       /bin/cp - wrong error on copying of multiple files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 06 16:00:33 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Edwin Groothuis
>Release:        FreeBSD 4.7-RELEASE i386
>Organization:
-
>Environment:
System: FreeBSD k7.mavetju 4.7-RELEASE FreeBSD 4.7-RELEASE #0: Mon Mar 3 09:15:38 EST 2003 edwin at k7.mavetju:/usr/src/sys/compile/k7 i386
FreeBSD ref5.freebsd.org 5.0-CURRENT FreeBSD 5.0-CURRENT #65: Sun Mar 30 09:00:38 PST 2003     root at ref5.freebsd.org:/usr/src/sys/i386/compile/REF5  i386

>Description:

If I copy multiple files to a directory which doesn't exist, it
gives me the usage screen instead of a message saying "cp: a: No
such directory".

>How-To-Repeat:

create directory a, don't create files b and c:

    [~] edwin at k7>/bin/cp c b a
    cp: b: No such file or directory
    cp: c: No such file or directory

    [~] edwin at k7>/bin/cp a b c
    usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
	   cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory

>Fix:

In cp.c, around line 213 (for the 4.7 sources) something like:
        if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
                /*
                 * Case (1).  Target is not a directory.
                 */
                if (argc > 1) {
-                       usage();
+			warnx(1,"Target is not a directory");
                        exit(1);
                }
                /*

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list