coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] [PATCH] md5sum: Add option to ignore non-existant files


From: Pádraig Brady
Subject: Re: [coreutils] [PATCH] md5sum: Add option to ignore non-existant files
Date: Sun, 22 Nov 2015 22:06:38 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 01/11/15 16:51, Pádraig Brady wrote:
> On 10/12/10 00:38, Pádraig Brady wrote:
>> On 09/12/10 03:14, Luther wrote:
>>> Normally, when I use md5sum, it's when I download a file and an MD5SUMS
>>> file that comes with it. This MD5SUMS file usually lists many files
>>> including the one I downloaded. When I run 'md5sum -c MD5SUMS', I get
>>> many error messages about files that I don't have. Obviously, I don't
>>> care about the files I didn't download, and the error messages make it
>>> difficult to see the output relating to the file that I do care about.
>>>
>>> I suggest a new option, -i/--ignore-missing, which ignores any filenames
>>> that do not exist on the filesystem.
>>>
>>> In my patch, the option simply suppresses both relevant error messages.
>>> Another approach might be to have digest_check check to see if the file
>>> exists. If it doesn't, don't call digest_file or print the 'FAILED'
>>> message.
>>>
>>> Sorry if my patch is a little messy, being in 3 parts. I'm not used to
>>> using git.
>>>
>>> HTH, and let me know what you think...
>>> Luther
>>
>> Thanks for the patch,
>> and sorry for the mailing list delay
>> (I'm not sure what moderation is done on these lists)
>>
>> So you would like to filter out the warnings.
>> Well they go to stderr, so you could just:
>>
>>   md5sum -c file.sum 2>/dev/null
>>
>> If you wanted to filter further to just FAILED you could:
>>
>>   md5sum -c file.sum 2>/dev/null | grep FAILED$
>>
>> It has the disadvantage of being longer to type
>> but the advantage of using existing tools and
>> options to do the filtering.  So at first glance
>> this option doesn't seem needed.
> 
> There was another request for this at
> https://bugzilla.redhat.com/1276664
> 
> Thinking further, one reason we might consider this is because
> currently open() and read() errors are not distinguished.
> You would want to treat a read() error like a checksum error,
> and not like an open()==ENOENT. Also other errors from open()
> should not be treated like ENOENT.
> 
> Another reason is because grep -E '(OK|FAILED)$' is locale dependent,
> so one would need LC_ALL=C md5sum ... | grep ...
> 
> Given the above and how common this use case is,
> I'd now be 60:40 for adding Luther's patch.

Updated patch attached.

cheers,
Pádraig.

Attachment: shasum-ignore-missing
Description: Text document


reply via email to

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