HomeFreeBSD

cp: Avoid prepending ./ in file-to-file case.

Description

cp: Avoid prepending ./ in file-to-file case.

  • Make to.base large enough to hold a trailing separator.
  • Remove the separator from warning and error messages.
  • In the FILE_TO_FILE case, leave to.base empty.
  • In the FILE_TO_DIR and DIR_TO_DNE cases, append a separator to to.base once we've (optionally created and) opened it.
  • Thus, in the file-to-file case, we print an empty string followed by to.path, while in all other cases, to.base already contains the necessary separator.

This fixes failures in tests that used cp and expected a specific
error message and were surprised to see "./" pop up.

Fixes: 82fc0d09e862
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D50357

Details

Provenance
desAuthored on May 15 2025, 11:54 AM
Reviewer
markj
Differential Revision
D50357: cp: Avoid prepending ./ in file-to-file case.
Parents
rGd90c9c24e2c3: vfs: vn_alloc(): Stop always calling vn_alloc_hard() and direct reclaiming
Branches
Unknown
Tags
Unknown