GNU bug report logs - #8370
RFC: cp --no-preserve=contents

Previous Next

Package: coreutils;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Mon, 28 Mar 2011 21:06:01 UTC

Severity: normal

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 8370 <at> debbugs.gnu.org, Eric Blake <eblake <at> redhat.com>
Subject: bug#8370: RFC: cp --no-preserve=contents
Date: Thu, 12 Apr 2012 16:13:43 +0100
On 04/12/2012 04:02 PM, Paul Eggert wrote:
> I like this idea too.  Some comments:
> 
>>  Preserve the specified attributes of the original files in the copy,
>> -but do not copy any data.  See the @option{--preserve} option for
>> -controlling which attributes to copy.
>> +but do not copy any data.  Data in existing destination files is not
>> +truncated.  See the @option{--preserve} option for controlling which
>> +attributes to copy.
> 
> The word "data" is plural.  But there is no need to talk about
> truncation: the point is that the file's contents aren't changed at
> all.  Something like this, maybe?
> 
>   Copy only the specified attributes of the source file to the destination.
>   If the destination already exists, do not alter its contents.
>   See the @option{--preserve} option for controlling which attributes to copy.
> 
> 
>> -      dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY);
>> +      /* We don't truncate with --attributes-only to support
>> +         copying attributes to an existing file.  */
>> +      dest_desc = open (dst_name, O_WRONLY | O_BINARY
>> +                        | (x->data_copy_required ? O_TRUNC : 0));
> 
> The indentation of the flags expression isn't right, and the
> comment is unnecessary clutter (the code is clear).  Perhaps something
> like this instead?
> 
>      int open_flags =
>        O_WRONLY | O_BINARY | (x->data_copy_required ? O_TRUNC : 0);
>      dest_desc = open (dst_name, open_flags);
> 

Cool.

thanks for the review,
Pádraig.




This bug report was last modified 13 years and 105 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.