Skip to content

Inconsistent behavior with GNU/POSIX cp with trailing /. #176

@autowert66

Description

@autowert66

Problem Description

The Deno task cp command behaves different that the system cp (GNU/POSIX) when used with a source that ends with a trailing /..

This breaks certain tasks that depend on that functionality to copy directory contents to a specific folder.

For example, consider a project that wants to copy the contents from a public/ folder into dist/:

cp -r public/. dist/

Using system cp, the above command copies the contents of public directly into dist/, which is the expected behavior. However, when using the deno task runner with the cp command, the /. is normalized away and deno creates dist/public with the contents of public/.

cp behavior explained (AI-generated)

In a standard POSIX-compliant system (like GNU coreutils on Linux), the . isn't stripped away indiscriminately. The command cp -r public/. dist/ relies on file system resolution:

  • public/. tells cp that the explicit source is the directory . (the current directory reference inside public).
  • It copies . and deposits it into dist, effectively resolving to dist/. (which is just dist).
  • As a result, the contents are merged directly into dist without creating a public subfolder.

Alternative workarounds:

An alternative to using the cp -r public/. dist/ command would be just using cp -r public/* dist/, however that would ignore hidden files and folders, such as .well-known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions