coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH]: add an option for quiet copy operations


From: Pádraig Brady
Subject: Re: [PATCH]: add an option for quiet copy operations
Date: Thu, 16 Feb 2012 14:20:27 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 02/16/2012 02:01 PM, Pádraig Brady wrote:
> On 02/16/2012 07:21 AM, Guido Trentalancia wrote:
>> Hello.
>>
>> I am writing to propose a simple patch for review. The patch adds an
>> option "-q" or "--quiet" to cp, mv and install so that they can support
>> quiet operation on missing SOURCE files.
>>
>> Such behavior might be useful for example when using any of the above
>> commands from scripts.
>>
>> The patch can be applied both to the git tree and to the latest release.
>>
>> Add an option "-q, --quiet" for cp, mv and install so that the program
>> does not complain about any missing SOURCE file.
>>
>> Signed-off-by: Guido Trentalancia <address@hidden>
> 
> Thanks a lot for taking time to do the patch.
> I'm not sure about it though.
> You could easily use other tools to filter non existent arguments.
> Something like:
> 
>   find file1 file2 -print0 2>/dev/null |
>   xargs -r0 cp --target=dest/
> 
> Or alternatively something like:
> 
>   cp $(realpath -e file1 file2 2>/dev/null) dest/
> 
> cheers,
> Pádraig.
> 
> p.s. Hmm, I wonder should `realpath -e` suppress ENOENT.
> readlink -e does

Ah now I remember.

readlink is --quiet by default (so the --quiet and --silent
options are largely redundant)

realpath diagnoses ENOENT etc. by default, unless --quiet is specified.
So a better form of the above command is:

  cp $(realpath -qe file1 file2) dest/

A caveat of the above, is that it doesn't handle spaces in filenames.
To do that you'd have to use something of the original form, like:

  realpath -zqe "file 1" "file2" |
  xargs -r0 cp --target=dest/

cheers,
Pádraig.



reply via email to

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