Skip to content

mv -u silently skips an entire directory when the destination directory has an equal or newer timestamp #17003

Backlog

Description

@limadog9

When the destination is an existing empty directory with an equal or newer modification time, mv -u exits 0 but leaves the entire source directory in place. A script that pre-creates a staging directory can continue to packaging with all the files from the move missing.

Reproduction

Run once per implementation with the mv under test on PATH.

cd "$(mktemp -d)" || exit 1
export LC_ALL=C
mkdir -p release stage/release
printf 'package\n' > release/manifest
touch -d @1000000000 release
touch -d @1000000001 stage/release

mv -u release stage/
printf 'mv exit: %s\n' "$?"
find . -name manifest -print

Expected (GNU Coreutils 9.7 and 9.12)

mv exit: 0
./stage/release/manifest

Actual (uutils 0.13.0 and main)

mv exit: 0
./release/manifest

Neither implementation prints a diagnostic. With uutils, stage/release remains empty. The GNU mv manual limits the timestamp skip to non-directory sources.

Source

In mv.rs, lines 827–838, (!from_is_dir || to_metadata.is_dir()) is true when both entries are directories. If the source mtime is less than or equal to the destination mtime, the function returns Ok(()) before attempting the rename.

Tested on Debian 13, x86-64 Linux 6.18.57, with uutils 0.13.0 (07b76df), upstream main (2a072db), and GNU Coreutils 9.7 and 9.12. I found no matching issue or PR. The related PR #15912 addressed dangling destination symlinks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions