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

Edwin Groothuis edwin at
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
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 06 16:00:33 PDT 2003
>Originator:     Edwin Groothuis
>Release:        FreeBSD 4.7-RELEASE i386
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 5.0-CURRENT FreeBSD 5.0-CURRENT #65: Sun Mar 30 09:00:38 PST 2003     root at  i386


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".


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


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");


More information about the freebsd-bugs mailing list