Index: bin/cp/cp.1 =================================================================== --- bin/cp/cp.1 +++ bin/cp/cp.1 @@ -32,7 +32,7 @@ .\" @(#)cp.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd June 6, 2015 +.Dd September 8, 2020 .Dt CP 1 .Os .Sh NAME @@ -96,8 +96,8 @@ copies the directory and the entire subtree connected at that point. If the .Ar source_file -ends in a -.Pa / , +ends in +.Pa /. , the contents of the directory are copied rather than the directory itself. This option also causes symbolic links to be copied, rather than Index: bin/cp/cp.c =================================================================== --- bin/cp/cp.c +++ bin/cp/cp.c @@ -101,6 +101,7 @@ enum op type; int Hflag, Lflag, ch, fts_options, r, have_trailing_slash; char *target; + char *p, **av; fts_options = FTS_NOCHDIR | FTS_PHYSICAL; Hflag = Lflag = 0; @@ -202,6 +203,14 @@ /* Set end of argument list for fts(3). */ argv[argc] = NULL; + + /* Strip trailing slashes from source files */ + for (av = argv; *av != NULL; av++) { + p = *av + strlen(*av); + while (p > *av + 1 && p[-1] == '/') + *--p = '\0'; + } + /* * Cp has two distinct cases: * Index: libexec/rc/rc.initdiskless =================================================================== --- libexec/rc/rc.initdiskless +++ libexec/rc/rc.initdiskless @@ -368,7 +368,7 @@ subdir=${j##*/} if [ -d $j -a ! -f $j.cpio.gz ]; then create_md $subdir - cp -Rp $j/ /$subdir + cp -Rp $j/. /$subdir fi done for j in /conf/$i/*.cpio.gz ; do Index: tools/regression/msdosfs/msdosfstest.sh =================================================================== --- tools/regression/msdosfs/msdosfstest.sh +++ tools/regression/msdosfs/msdosfstest.sh @@ -9,7 +9,7 @@ bsdlabel -w md10 auto newfs_msdos -F 16 -b 8192 /dev/md10a mount_msdosfs /dev/md10a /tmp/msdosfstest/ -cp -R /usr/src/bin/ /tmp/msdosfstest/ +cp -R /usr/src/bin/. /tmp/msdosfstest/ umount /tmp/msdosfstest/ mount_msdosfs /dev/md10a /tmp/msdosfstest/ diff -u -r /usr/src/bin /tmp/msdosfstest/