uutils / uutils/coreutils

inconsistent behaviour between GNU and uutils `mv` for symlink-<slash> as source

Open
#10,026 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - mv
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

Component

mv

Inconsistent Behaviour

To reproduce

mkdir foo-dir
ln -s foo-dir foo-link
gmv foo-link/ foo-dir # gmv cuz I'm on MacOS
uu-mv foo-link/ foo-dir

gmv returns gmv: cannot move 'link-to-dir/' to 'testdir/link-to-dir': Not a directory

While uu-mv returns uu-mv: cannot move 'link-to-dir/' to a subdirectory of itself, 'testdir/link-to-dir'

This was raised when I was experimenting to resolve #5451.

Cause and fix

src/uu/mv/src/mv.rs lacks in a checking mechanism (path_ends_with_terminator + is_symlink) for source. It goes all the way into checking if source and target are the same before throwing the error.

Could insert this mechanism at line 397.

If this issue is valid, can I claim and work on it?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction commands using gmv and uu-mv, then inspect src/uu/mv/src/mv.rs around line 397 and the mentioned path_ends_with_terminator and is_symlink checks. Done means uu-mv reports the same not-a-directory behavior as GNU mv for a symlink with a trailing slash.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.