"cp -i -f": -f does not override -i like it does in other coreutils

Bug #925876 reported by Nathan O'Sullivan
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Confirmed
Wishlist
Unassigned

Bug Description

In some environments, cp / mv / rm will be aliased to 'cp -i' 'mv -i' 'rm -i' to reduce the chance of data loss.

mv and rm allow -f to force overwrite (even when -i is used); but cp does not - which is both inconsistent with the other tools and annoying in such alias'd environments. Example:

nats@nathan:~$ bash --norc
bash-4.2$ alias cp='cp -i'
bash-4.2$ alias rm='rm -i'
bash-4.2$ alias mv='mv -i'
bash-4.2$ touch file1
bash-4.2$ touch file2
bash-4.2$ cp -f file1 file2
cp: overwrite `file2'? y
bash-4.2$ mv -f file1 file2
bash-4.2$ rm -f file2

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: coreutils 8.5-1ubuntu6
ProcVersionSignature: Ubuntu 3.0.0-14.23-generic 3.0.9
Uname: Linux 3.0.0-14-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Fri Feb 3 15:44:01 2012
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
ProcEnviron:
 LANGUAGE=en_AU:en
 PATH=(custom, no user)
 LANG=en_AU.UTF-8
 SHELL=/bin/bash
SourcePackage: coreutils
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Nathan O'Sullivan (nathan-mammoth) wrote :
Revision history for this message
C de-Avillez (hggdh2) wrote :

Thank you for opening this bug and helping make Ubuntu better.

Indeed 'cp' behaviour is different.

cp: specifying '-i' (alternatively, '-f') does not override a previous '-f' (alternatively, '-i)
mv, rm: the final '-i' or '-f' in the parameter's sequence will win

This will need a bit of re-reading the info pages -- these options are not quite the same on all commands.

Now you do realise that you can use '-nf' as an override on 'cp', right?

For now, marking Confirmed/WishList
rm:

Changed in coreutils (Ubuntu):
importance: Undecided → Wishlist
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.