bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cp/mv: add -n option to not overwrite target (Ubuntu bug #229182)


From: Jim Meyering
Subject: Re: cp/mv: add -n option to not overwrite target (Ubuntu bug #229182)
Date: Wed, 07 Jan 2009 20:27:01 +0100

Kamil Dudka <address@hidden> wrote:
> On Wednesday 07 January 2009 17:08:04 Jim Meyering wrote:
>> --no-clobber gets a few more matches in C sources than --no-overwrite,
>>
>>   57  http://www.google.com/codesearch?q=\-\-no\-clobber+lang:c
>>   40  http://www.google.com/codesearch?q=\-\-no\-overwrite+lang:c
>>
>> Regarding uses, it appears to outnumber --no-overwrite 2-to-1.
>>
>> Anyone else have a preference?
> Now the option is --no-clobber in attached patch. Anyway the change is
> trivial. No problem to change it if there will be a consensus
> for --no-overwrite or something else.
>
>> My point is that depending on when you test for
>> the existence of the destination file, you could say that with
>> --backup, there is never an existing destination file, since
>> it's always moved aside before the "open".  In *that* case,
>> you would expect the "-n" in "--backup -n" to be ignored.
>> This ambiguity is why the semantics of "--backup -n" must be
>> documented explicitly.
> Ok, mentioned in documentation of option -n.
>
>> Since there are three copies of that new sentence in coreutils.texi,
>>
>>     If you specify more than one of the @option{-i}, @option{-f},
>>     @option{-n} options, only the final one takes effect.
>>
>> would you please put it in a macro?
> Ok, new patch attached.

Thanks!  Almost done, I think.
Unless anyone pipes up about the choice of long option name.

> address@hidden -n
> address@hidden --no-clobber
> address@hidden -n
> address@hidden --no-clobber
> +Do not overwrite an existing file. The @option{-n} option overrides a 
> previous
> address@hidden option. This option turns off the backup.

These semantics might be a little surprising, or even dangerous.
Imagine I run cp -n --backup=numbered important-file backup,
thinking that it's just made a backup of the old version and
I can now safely destroy "important-file".

What do you think about making cp/mv fail if -n and --backup are used together?
Then there would be no risk of misunderstanding.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]