Skip to content

feat: cp & mv should not overwrite recently created files #631

@nfischer

Description

@nfischer

If you have a copy command like:

$ cp file1.txt out/file1.txt destination/

You should get an error that says something like:

cp: will not overwrite just-created ‘destination/file1.txt’ with ‘out/file1.txt’

We're currently silently overwriting files that we created in that same copy command, but should instead provide a warning and refuse to copy the second file.

The behavior should stay the same with -f and -r, but cp does not give the warning with directories or their contents.

$ cp dir1 out/dir1 destination/ # never has this error
$ ls destination/dir1/ # shows the merged contents of both ./dir1/ and out/dir1/

The warning is never present with the -n flag.

This warning should also be presented for the mv command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bash compatCompatibility issues with bash or POSIX behaviorfixBug/defect, or a fix for such a problemhelp wantedlow priority

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions