mv --exchange with one source swaps the entire target directory without -T

Đang mở
#16,778 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

The bug is in the two-operand branch of exchange_paths in src/uu/mv/src/mv.rs, which passes the target directory itself to exchange_two_paths instead of the path inside it. Read that branch and compare it with the -T and multiple-source handling, then reproduce with the shell snippet in the issue. Done means one source with a populated target directory and no -T swaps the source with target/<source basename>, exits 0 as GNU does, and a regression test in the mv test suite covers this case.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

With one source and no -T, mv --exchange manifest release/ swaps the file with the whole release directory and exits 0. Unrelated files move with it.

work=$(mktemp -d) && cd "$work" || exit 1
mkdir release
printf 'staged\n' > manifest
printf 'current\n' > release/manifest
printf 'other\n' > release/notes
mv --exchange manifest release/
find . -type f | LC_ALL=C sort

GNU swaps manifest and release/manifest. The unrelated file stays at release/notes. On uutils, release is now a regular file containing staged, and the entire directory is now at manifest (including manifest/notes and manifest/manifest).

Repeating in a fresh directory without release/manifest, GNU exits 1 and leaves both paths in place. uutils still exchanges the directory and exits 0. With explicit -T, both implementations exchange the whole directory.

Verified on x86_64 Linux with uutils 0.12.0, 0.13.0 and main at 8b16a3dca86ae91df73db3d375205eb7718c4c03 against GNU 9.7 and 9.12. The two-operand arm of exchange_paths passes the target directory itself to exchange_two_paths. Existing tests cover -T and multiple sources. A regression test with one source and a populated target directory without -T would catch this. https://github.com/uutils/coreutils/blob/8b16a3dca86ae91df73db3d375205eb7718c4c03/src/uu/mv/src/mv.rs#L640-L657

Ngôn ngữ chính
Rust
Star
24.4k
Fork
2.2k
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
402

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uutils/coreutils

Tất cả issue của uutils/coreutils

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.