Repository navigation
cp: -n is I_ALWAYS_NO per pristine GNU 9.4 (#1879) - #1978
Conversation
-n mapped to Interactive::AlwaysNo (cp.c:1070) instead of the Ubuntu .deb's silent AlwaysSkip: an existing destination now reports 'not replacing <dst>' and fails the file (copy.c:2438), a fresh copy under -n prints nothing, and the .deb-only deprecation warning is gone (no_clobber_seen deleted; make_backups added for the cp.c:1220 --backup/--no-clobber mutual exclusion, set by -b/--backup and -S/--suffix per cp.c:1027/1191). --update=none keeps the silent AlwaysSkip form. New i18n keys: command.cp.error.not_replacing, command.cp.error.backup_and_no_clobber (mv precedent). Refs #1879 (not Fixes).
… .deb The three -n-final rows were calibrated against the WSL distro's Ubuntu .deb cp 9.4, whose -n is patched to a silent rc-0 skip. The pristine coreutils 9.4 tarball oracle (this project's standard) prints "cp: not replacing '<dst>'" and exits 1 for exactly these combinations (-n, -nv, -nv --update=all, -v -i -n), matching the port after this PR. The rows stay as record-only (note) so both sides keep being measured without gating on the .deb divergence.
|
CAPTAIN adjudication of the CI reds on this PR (2026-11-30): i18n-drift — expected red until winuxcmd-i18n #43 (the two new cp keys) merged; it has now merged, so this job should go green on the next run. rust2-gate, cp32 / cp34 / cp39 (3 FAIL rows) — not a port regression; a gate-calibration defect. All three rows are the combinations where
The port after this PR matches the pristine oracle on every row. I have set cp32/cp34/cp39 to |
Refs #1879
UNVERIFIED-BY-CAPTAIN — lane delivery, code only. Captain to verify via CI
(full rust tests + CTest) before merge.
What
cp -nnow follows pristine GNU coreutils 9.4 instead of the Ubuntu9.4-3ubuntu6.2 build's patched behavior (the port's original oracle):
-nmaps toI_ALWAYS_NO(cp.c:1070), not the silentI_ALWAYS_SKIP.An existing destination is reported and fails the file:
cp: not replacing '<dst>', rc 1 (copy.c:2438). A fresh copy under-nprints nothing.
--update=nonekeeps the silent-skip form, rc 0.(
warning: behavior of -n is non-portable..., absent from the pristine9.4 tree) is no longer printed.
-ncombined with backups is the cp.c:1220 usage erroroptions --backup and --no-clobber are mutually exclusive— for-b/--backupwith any control (including--backup=none) and for-S/--suffix(both setmake_backups, cp.c:1027/1191), whether ornot a destination exists yet.
-nis active, an explicit--update=WHENis not argmatched(cp.c:1136), so
-n --update=allno longer restores copying;-i/-nlast-wins is unchanged (
-niprompts,-inreportsnot replacing).The
mvport already implements exactly this state machine; this changebrings
cponto the same single mechanism (including thecommand.*.error.not_replacing/...backup_and_no_clobberkey shapes).Oracle evidence (pristine coreutils 9.4 tarball build, cloud oracle):
cp -n a keep→not replacing 'keep', rc 1;cp -n a fresh→ silent,rc 0; dir-target skip reports the joined path;
-n a a→not replacing;-n -b,-nb,-n --backup=none,-n -S .bak→ mutual-exclusion usageerror;
--update=nonefaces all silent rc 0.What this PR deletes
cp_cmd.no_clobber_seenoption field and all its assignments (its onlyreader was the warning).
.deb-behavior assertions in three tests (rewritten to pristinebehavior, see below). No second mechanism is introduced:
-nand--update=nonestop sharing one silent branch and take GNU's twoexisting states.
Tests
Rewritten:
no_clobber_skip_reports_not_replacing,interactive_and_no_clobber_are_last_wins,no_clobber_skips_existing_and_copies_new,update_all_after_no_clobber_does_not_restore_copying.New:
update_none_skips_silently,no_clobber_same_file_reports_not_replacing,no_clobber_and_backup_are_mutually_exclusive,no_clobber_skip_inside_directory_target_reports_joined_path.Net lines
Production +67/−39 (net +28); tests +100/−21 (net +79).
i18n (companion, captain-side)
tr!):command.cp.error.not_replacing,command.cp.error.backup_and_no_clobber— winuxcmd-i18n sync PR needsthe zh entries + VERSION bump.
command.cp.warning.no_clobber_deprecatedis now unreferenced —orphan-key deletion PR in winuxcmd-i18n (not
--update-baseline).command.cp.option.no-clobber("…也不报错") should beadjusted in the sync PR;
-ndoes report now.Deliberately unchanged
-Salone still creates no backup (the port's documented divergencefrom the tarball, where
make_backupsalso drivesbackup_type);here
make_backupsis tracked only for the cp.c:1220 conflict check.