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

Aperta
#16,778 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Rust
Stelle
24.4k
Fork
2.2k
Merge medio
2g 23h
PR unite (30g)
402

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di uutils/coreutils

Tutte le issue di uutils/coreutils

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.