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: Pádraig Brady
Subject: Re: cp/mv: add -n option to not overwrite target (Ubuntu bug #229182)
Date: Tue, 6 Jan 2009 15:50:19 +0000
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Kamil Dudka wrote:
> Thanks for review.
> 
> On Tuesday 23 December 2008 01:37:54 Pádraig Brady wrote:
>> For my own reference this is how I now see
>> the overwrite characteristics of cp & mv:
>>
>> cp : default overwrite method = truncate only (file must be writable)
>>   -f overwrite method = truncate falling back to unlink+create
>>      (redundant if the -n option is used)
>>   --remove-destination
>>      overwrite method = unlink+create
>>      (redundant if the -n option is used)
> Should I mention this in documentation and/or help?

I would, at least for the -f option as
it's not obvious it doesn't override -n

>>   -i prompt before trying to overwrite dest
>>      (overrides any preceeding -n option)
>>   -n never overwrite
>>      (overrides any preceeding -i option)
>>
>> mv : prompt to overwrite if dest not writable
>>   -f never prompt before overwriting
>>      (overrides any preceeding -i or -n options)
>>   -i always prompt before overwriting
>>      (overrides any preceeding -f or -n options)
>>   -n never overwrite
>>      (overrides any preceeding -f or -i options)
> So in the case of mv there is no violation with FreeBSD implementation, nor 
> POSIX.

right.

>> p.s. According to the FreeBSD manpages referenced in this thread,
>> cp -f in FreeBSD doesn't conform to POSIX, and instead
>> means as I originally thought: "try best to overwrite _and don't prompt_."
>> I.E. it overrides any preceeding -i or -n options.
> Yes, the behavior of FreeBSD cp -f option differs from POSIX and this patch.
> 
> Up to date version of the patch is attached.

A couple of tweaks needed I think:

                                a
The @option{-i} option overrides previous @option{-n} option
                                ^
Same tweak suggested for both the cp usage() function.

In the tests you set LC_ALL=C explicitly.
I don't think this is necessary as the locale
is set to C by default (using the tests/lang-default script).

cheers,
Pádraig.






reply via email to

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