Skip to content

Conversation

@Vitamin9C
Copy link

@Vitamin9C Vitamin9C commented Jan 4, 2026

Description

Resolve problems described in #10026

  • Unaligned error message with GNU
  • Problematic behavior on running mv symlink_foo/ bar (will move symlink destination folder or file to bar)

Changes

  • Added one helper function in uucore::fs (compare other helper functions used in mv like path_ends_with_terminator, are_hardlinks_to_same_file). (Didn't reuse path_ends_with_terminator in Unix implementation for performance, reused it in Windows implementation cuz Windows U16 would worsen the performance anyway)
  • Added a segment in mv.rs to handle symlink_to_file/ and symlink_to_dir/ as mv source correctly and consistently with GNU.
  • Added a new MvError CannotMoveNotADirectory with error code mv-error-cannot-move-not-directory with en-US and fr-FR locales.
  • Added 6 tests under the pattern of mv symlink/ target which would fail before this PR.

@Vitamin9C Vitamin9C force-pushed the PR-mv-symlinkslash branch 2 times, most recently from d15e43f to 341c0f4 Compare January 5, 2026 02:03
@Vitamin9C
Copy link
Author

Vitamin9C commented Jan 5, 2026

The error messages of the failures in CI for win actually matches the error messages yielded with GNU Coreutils on Windows (which is different from GNU Coreutils on my local MacOS). It's just we need to craft these 3 tests for Unix and Windows with different expected values.

# MacOS
 ~/Wo/2026/tests  ls -al                          1 х │ system Node │ 08:09:45
total 0
drwxr-xr-x 6 schen 192 Jan  5 08:09 .
drwxr-xr-x 6 schen 192 Jan  3 13:09 ..
-rw-r--r-- 1 schen   0 Jan  5 08:09 a
drwxr-xr-x 2 schen  64 Jan  5 08:09 bar-dir
drwxr-xr-x 2 schen  64 Jan  5 08:09 foo-dir
lrwxr-xr-x 1 schen   7 Jan  5 08:09 foo-link -> foo-dir
 ~/Wo/2026/tests  gmv foo-link/ a                   ✔ │ system Node │ 08:09:50
gmv: cannot overwrite non-directory 'a' with directory 'foo-link/'
 ~/Wo/2026/tests  gmv foo-link/ foo-dir           1 х │ system Node │ 08:10:26
gmv: cannot move 'foo-link/' to 'foo-dir/foo-link': Not a directory
 ~/Wo/2026/tests  gmv foo-link/ bar-dir           1 х │ system Node │ 08:10:32
gmv: cannot move 'foo-link/' to 'bar-dir/foo-link': Not a directory
# Win
C:\Workspace\Personal\uutils>ls -al
total 8
drw-rw-rw-  4 chens 0    0 2026-01-05 08:07 .
drw-rw-rw-  7 chens 0 4096 2026-01-05 08:03 ..
-rw-rw-rw-  1 chens 0    0 2026-01-05 08:04 a
drw-rw-rw-  2 chens 0    0 2026-01-05 08:07 bar-dir
drw-rw-rw-  2 chens 0    0 2026-01-05 08:04 foo-dir
lr--r--r--  1 chens 0  838 2026-01-05 08:04 foo-link.lnk -> C:/Workspace/Personal/uutils/foo-dir

C:\Workspace\Personal\uutils>mv foo-link\ a
mv: cannot stat `foo-link\\': No such file or directory

C:\Workspace\Personal\uutils>mv foo-link\ foo-dir
mv: cannot stat `foo-link\\': No such file or directory

C:\Workspace\Personal\uutils>mv foo-link/ bar-dir
mv: cannot stat `foo-link/': No such file or directory

@sylvestre
Copy link
Contributor

please replace the screenshots by text

@Vitamin9C
Copy link
Author

Sorry I forgot to fmt before the last commit...... force-pushed again to prevent consuming CI time.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@Vitamin9C Vitamin9C changed the title Fix mv <symlink>/ target for various situations. Align error message … Fix mv <symlink>/ target for various situations. Align error message with GNU Jan 5, 2026
@Vitamin9C
Copy link
Author

Vitamin9C commented Jan 7, 2026

Hi @sylvestre. I wonder if I can do something further to get this PR be improved, reviewed, and merged? It's my first PR to this project and I wish to improve its quality and do better to contribute.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants